working on it ...

Filters

Explore Public Snippets

Sort by

Found 88 snippets matching: azure-stream-analytics-master

    public by Geometry  103610  4  5  0

    ResolveToEndPoint

    ResolveToEndPoint
    using System;
    using System.Linq;
    using System.Net;
    using System.Collections.Generic;
    
    public static IPEndPoint ResolveToEndPoint(string value)
    {
    	if (String.IsNullOrEmpty(value))
    		throw new ArgumentNullException("value");
    
    	var parts = value.Split(':');
    	if (parts.Length != 2)
    		throw new ArgumentException("host:port is expected", "value");
    
    	int port;
    	if (!Int32.TryParse(parts[1], out port))
    		throw new ArgumentException("Cannot parse port: " + parts[1], "value");
    
    	return ResolveToEndPoint(parts[0], port);
    }

    public by Geometry  50815  0  4  0

    Allows bool to be BindableWithTypeConverter

    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Diagnostics.CodeAnalysis;
    using System.Globalization;
    using System.Linq;
    using System.Net.Http;
    using System.Net.Http.Headers;
    using System.Web.Http;
    using System.Web.Http.Controllers;
    using System.Web.Http.Description;
    using PowerBIRestDemo.Areas.HelpPage.ModelDescriptions;
    using PowerBIRestDemo.Areas.HelpPage.Models;
    
    private static bool IsBindableWithTypeConverter(Type parameterType)
    {
        if (parameterType == null)
        {
            return false;
        }
    
        return TypeDescriptor.GetConverter(parameterType).CanConvertFrom(typeof(string));
    }

    public by Geometry  45186  0  4  0

    Main: The main entry point for the application.

    The main entry point for the application.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new MainForm());
    }

    public by Geometry  42788  0  4  0

    Provides ParseTwitterDateTime

    Provides ParseTwitterDateTime
    using Newtonsoft.Json.Linq;
    using System;
    using System.Globalization;
    using System.IO;
    using System.Net;
    using System.Text;
    using System.Web;
    
    static DateTime ParseTwitterDateTime(string p)
    {
        if (p == null)
            return DateTime.Now;
        p = p.Replace("+0000 ", "");
        DateTimeOffset result;
    
        if (DateTimeOffset.TryParseExact(p, "ddd MMM dd HH:mm:ss yyyy", CultureInfo.GetCultureInfo("en-us").DateTimeFormat, DateTimeStyles.AssumeUniversal, out result))
            return result.DateTime;
        else
            return DateTime.Now;
    }

    public by Geometry  39381  0  4  0

    Allows to InitializeGenerators

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Diagnostics.CodeAnalysis;
    using System.Globalization;
    using System.Linq;
    using System.Reflection;
    
    [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "These are simple type factories and cannot be split up.")]
    private static Dictionary<Type, Func<long, object>> InitializeGenerators()
    {
        return new Dictionary<Type, Func<long, object>>
        {
            { typeof(Boolean), index => true },
            { typeof(Byte), index => (Byte)64 },
            { typeof(Char), index => (Char)65 },
            { typeof(DateTime), index => DateTime.Now },
            { typeof(DateTimeOffset), index => new DateTimeOffset(DateTime.Now) },
            { typeof(DBNull), index => DBNull.Value },
            { typeof(Decimal), index => (Decimal)index },
            { typeof(Double), index => (Double)(index + 0.1) },
            { typeof(Guid), index => Guid.NewGuid() },
            { typeof(Int16), index => (Int16)(index % Int16.MaxValue) },
            { typeof(Int32), index => (Int32)(index % Int32.MaxValue) },
            { typeof(Int64), index => (Int64)index },
            { typeof(Object), index => new object() },
            { typeof(SByte), index => (SByte)64 },
            { typeof(Single), index => (Single)(index + 0.1) },
            { 
                typeof(String), index =>
                {
                    return String.Format(CultureInfo.CurrentCulture, "sample string {0}", index);
                }
            },
            { 
                typeof(TimeSpan), index =>
                {
                    return TimeSpan.FromTicks(1234567);
                }
            },
            { typeof(UInt16), index => (UInt16)(index % UInt16.MaxValue) },
            { typeof(UInt32), index => (UInt32)(index % UInt32.MaxValue) },
            { typeof(UInt64), index => (UInt64)index },
            { 
                typeof(Uri), index =>
                {
                    return new Uri(String.Format(CultureInfo.CurrentCulture, "http://webapihelppage{0}.com", index));
                }
            },
        };
    }

    public by Geometry  22312  0  4  0

    Allows to GenerateRequestModelDescription

    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Diagnostics.CodeAnalysis;
    using System.Globalization;
    using System.Linq;
    using System.Net.Http;
    using System.Net.Http.Headers;
    using System.Web.Http;
    using System.Web.Http.Controllers;
    using System.Web.Http.Description;
    using PowerBIRestDemo.Areas.HelpPage.ModelDescriptions;
    using PowerBIRestDemo.Areas.HelpPage.Models;
    
    private static void GenerateRequestModelDescription(HelpPageApiModel apiModel, ModelDescriptionGenerator modelGenerator, HelpPageSampleGenerator sampleGenerator)
    {
        ApiDescription apiDescription = apiModel.ApiDescription;
        foreach (ApiParameterDescription apiParameter in apiDescription.ParameterDescriptions)
        {
            if (apiParameter.Source == ApiParameterSource.FromBody)
            {
                Type parameterType = apiParameter.ParameterDescriptor.ParameterType;
                apiModel.RequestModelDescription = modelGenerator.GetOrCreateModelDescription(parameterType);
                apiModel.RequestDocumentation = apiParameter.Documentation;
            }
            else if (apiParameter.ParameterDescriptor != null &&
                apiParameter.ParameterDescriptor.ParameterType == typeof(HttpRequestMessage))
            {
                Type parameterType = sampleGenerator.ResolveHttpRequestMessageType(apiDescription);
    
                if (parameterType != null)
                {
                    apiModel.RequestModelDescription = modelGenerator.GetOrCreateModelDescription(parameterType);
                }
            }
        }
    }

    public by Geometry  20132  0  4  0

    Allows to GetResponse

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Configuration;
    using Microsoft.IdentityModel.Clients.ActiveDirectory;
    using System.Net;
    using System.IO;
    using PowerBI;
    
    private static string GetResponse(HttpWebRequest request)
    {
        string response = string.Empty;
    
        using (HttpWebResponse httpResponse = request.GetResponse() as System.Net.HttpWebResponse)
        {
            //Get StreamReader that holds the response stream
            using (StreamReader reader = new System.IO.StreamReader(httpResponse.GetResponseStream()))
            {
                response = reader.ReadToEnd();
            }
        }
    
        return response;
    }

    public by Geometry  1315  14  5  0

    Allows to GetModelName

    Modify this to provide custom model name mapping.
    using System;
    using System.Globalization;
    using System.Linq;
    using System.Reflection;
    
    // Modify this to provide custom model name mapping.
    public static string GetModelName(Type type)
    {
        ModelNameAttribute modelNameAttribute = type.GetCustomAttribute<ModelNameAttribute>();
        if (modelNameAttribute != null && !String.IsNullOrEmpty(modelNameAttribute.Name))
        {
            return modelNameAttribute.Name;
        }
    
        string modelName = type.Name;
        if (type.IsGenericType)
        {
            // Format the generic type name to something like: GenericOfAgurment1AndArgument2
            Type genericType = type.GetGenericTypeDefinition();
            Type[] genericArguments = type.GetGenericArguments();
            string genericTypeName = genericType.Name;
    
            // Trim the generic parameter counts from the name
            genericTypeName = genericTypeName.Substring(0, genericTypeName.IndexOf('`'));
            string[] argumentTypeNames = genericArguments.Select(t => GetModelName(t)).ToArray();
            modelName = String.Format(CultureInfo.InvariantCulture, "{0}Of{1}", genericTypeName, String.Join("And", argumentTypeNames));
        }
    
        return modelName;
    }

    public by Geometry  1843  8  4  0

    GetDeviceService: Finds the GattDeviceService by sensorServiceUuid. IMPORTANT: Has to be called from UI thread the first time the app uses the device to be able to ask the user for permission to use it.

    Finds the GattDeviceService by sensorServiceUuid. IMPORTANT: Has to be called from UI thread the first time the app uses the device to be able to ask the user for permission to use it. Returns the gatt device service of the first device that supports it. Returns null if access is denied. Thrown if there isn't a device which provides the service Uu
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Windows.Devices.Bluetooth.GenericAttributeProfile;
    using Windows.Devices.Enumeration;
    using Windows.Storage.Streams;
    using X2CodingLab.SensorTag.Exceptions;
    using X2CodingLab.Utils;
    
    /// <summary>
    /// Finds the GattDeviceService by sensorServiceUuid.
    /// IMPORTANT: Has to be called from UI thread the first time the app uses the device to be able to ask the user for permission to use it.
    /// </summary>
    /// <returns>Returns the gatt device service of the first device that supports it. Returns null if access is denied.</returns>
    /// <exception cref="DeviceNotFoundException">Thrown if there isn't a device which provides the service Uuid.</exception>
    public async static Task<GattDeviceService> GetDeviceService(string serviceUuid)
    {
        Validator.RequiresNotNullOrEmpty(serviceUuid);
    
        string selector = GattDeviceService.GetDeviceSelectorFromUuid(new Guid(serviceUuid));
        var devices = await DeviceInformation.FindAllAsync(selector);
        DeviceInformation di = devices.FirstOrDefault();
    
        if (di == null)
            throw new DeviceNotFoundException();
    
        return await GattDeviceService.FromIdAsync(di.Id);
    }

    public by Geometry  421  21  4  -1

    Allows to GetParameterDescriptions

    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Net.Http.Headers;
    using System.Web.Http.Description;
    using PowerBIRestDemo.Areas.HelpPage.ModelDescriptions;
    
    private static IList<ParameterDescription> GetParameterDescriptions(ModelDescription modelDescription)
    {
        ComplexTypeModelDescription complexTypeModelDescription = modelDescription as ComplexTypeModelDescription;
        if (complexTypeModelDescription != null)
        {
            return complexTypeModelDescription.Properties;
        }
    
        CollectionModelDescription collectionModelDescription = modelDescription as CollectionModelDescription;
        if (collectionModelDescription != null)
        {
            complexTypeModelDescription = collectionModelDescription.ElementDescription as ComplexTypeModelDescription;
            if (complexTypeModelDescription != null)
            {
                return complexTypeModelDescription.Properties;
            }
        }
    
        return null;
    }
    • Public Snippets
    • Channels Snippets