public System.Collections.Generic.IEnumerable<NativeCimClass> QueryClasses (NativeDestinationOptions options, string namespaceName, string queryDialect, string queryExpression) { var context = new EnumerationContext(CimNamespaces.CimNamespace, new Filter(queryDialect, new CimEnumerationFilter { Namespace = namespaceName, Filter = queryExpression }), new Selector[0]); foreach (EndpointAddress address in _handler.Enumerate (context)) { yield return CimEnumerationHelper.CreateClass (address); } }
public static NativeDestinationOptions GetDestinationOptions(SessionHandle handle) { NativeCimSession session = MarshalledObject.FromPointer <NativeCimSession> (handle.DangerousGetHandle()); NativeDestinationOptions options = new NativeDestinationOptions(); if (session.DestinationOptions == IntPtr.Zero) { /* Setup Default Destination Options */ options.ServerName = session.ServerName; options.DestinationPort = 5985; } else { options = MarshalledObject.FromPointer <NativeDestinationOptions> (session.DestinationOptions); if (string.IsNullOrEmpty(options.ServerName)) { options.ServerName = session.ServerName; } if (options.DestinationPort == 0) { options.DestinationPort = 5985; } } return(options); }
public static INativeCimHandler GetHandler(NativeDestinationOptions options) { if (string.IsNullOrEmpty(options.ServerName) || options.ServerName.Equals("localhost", StringComparison.OrdinalIgnoreCase)) { return(LocalHandler); } return(Handler); }
public System.Collections.Generic.IEnumerable<NativeCimClass> QueryClasses (NativeDestinationOptions options, string namespaceName, string queryDialect, string queryExpression) { var client = CreateClient(options, queryDialect); foreach (EndpointAddress item in client.EnumerateEPR(new Uri(CimNamespaces.CimNamespace), new Filter(queryDialect, new CimEnumerationFilter { Namespace = namespaceName, Filter = queryExpression }), BatchSize)) { yield return CimEnumerationHelper.CreateClass (item); } }
private EnumerationClient CreateClient (NativeDestinationOptions options, string queryDialect) { string serverName = string.IsNullOrEmpty (options.ServerName) ? "localhost" : options.ServerName; serverName = "localhost"; int port = options.DestinationPort <= 0 ? 5985 : options.DestinationPort; string prefix = string.IsNullOrEmpty (options.UrlPrefix) ? "http://" : options.UrlPrefix; var binding = new WSManBinding(); ChannelFactory<IWSEnumerationContract> cf = new ChannelFactory<IWSEnumerationContract>(binding); cf.Credentials.UserName.UserName = options.UserName; cf.Credentials.UserName.Password = options.Password; EnumerationClient client = new EnumerationClient(true, new Uri(string.Format("{0}{1}:{2}/wsman", prefix, serverName, port)), cf); client.BindFilterDialect(queryDialect, typeof(CimEnumerationFilter)); return client; }
internal static unsafe MiResult Clone (DestinationOptionsHandle destinationOptionsHandle, out DestinationOptionsHandle newDestinationOptionsHandle) { if (destinationOptionsHandle != null) { newDestinationOptionsHandle = destinationOptionsHandle; } else { NativeDestinationOptions options = new NativeDestinationOptions(); IntPtr optionsPtr = (IntPtr)CimNativeApi.MarshalledObject.Create<NativeDestinationOptions>(options); newDestinationOptionsHandle = new DestinationOptionsHandle(optionsPtr); } /* DangerousHandleAccessor dangerousHandleAccessor = null; DangerousHandleAccessor modopt(System.Runtime.CompilerServices.IsConst) dangerousHandleAccessor modopt(System.Runtime.CompilerServices.IsConst) = new DangerousHandleAccessor(destinationOptionsHandle); try { dangerousHandleAccessor = dangerousHandleAccessor modopt(System.Runtime.CompilerServices.IsConst); _MI_DestinationOptions* _MIDestinationOptionsPointer = (_MI_DestinationOptions*)((void*)dangerousHandleAccessor.DangerousGetHandle()); if (_MIDestinationOptionsPointer != null) { if ((long)(*(_MIDestinationOptionsPointer + (long)16)) != 0) { newDestinationOptionsHandle = null; _MI_DestinationOptions* _MIDestinationOptionsPointer1 = (_MI_DestinationOptions*)<Module>.Microsoft.Management.Infrastructure.Native.MI_CLI_malloc_core((long)24); _MI_Result _MIResult = (_MI_Result)<Module>.?A0x5fa54d02.MI_DestinationOptions_Clone(_MIDestinationOptionsPointer, _MIDestinationOptionsPointer1); if (_MIResult != 0) { <Module>.free(_MIDestinationOptionsPointer1); dangerousHandleAccessor.Dispose(); return (MiResult)_MIResult; } else { IntPtr intPtr = (IntPtr)_MIDestinationOptionsPointer1; newDestinationOptionsHandle = new DestinationOptionsHandle(intPtr); dangerousHandleAccessor.Dispose(); return (MiResult)_MIResult; } } } } dangerousHandleAccessor.Dispose(); */ return MiResult.OK; }
/// <summary> /// Queries the classes. /// </summary> /// <returns> /// The classes. /// </returns> /// <param name='namespaceName'> /// Namespace name. /// </param> /// <param name='queryDialect'> /// Query dialect. /// </param> /// <param name='queryExpression'> /// Query expression. /// </param> public static IEnumerable <NativeCimClass> QueryClasses(NativeDestinationOptions options, string namespaceName, string queryDialect, string queryExpression) { return(GetHandler(options).QueryClasses(options, namespaceName, queryDialect, queryExpression)); }
public static NativeCimInstance InvokeMethod(NativeDestinationOptions options, string namespaceName, string className, string methodName, NativeCimInstance instance, NativeCimInstance inSignature) { return(GetHandler(options).InvokeMethod(namespaceName, className, methodName, instance, inSignature)); }
/// <summary> /// Queries the instances. /// </summary> /// <returns> /// The instances. /// </returns> /// <param name='namespaceName'> /// Namespace name. /// </param> /// <param name='queryDialect'> /// Query dialect. /// </param> /// <param name='queryExpression'> /// Query expression. /// </param> /// <param name='keysOnly'> /// If set to <c>true</c> keys only. /// </param> public static IEnumerable <NativeCimInstance> QueryInstances(NativeDestinationOptions options, string namespaceName, string queryDialect, string queryExpression, bool keysOnly) { return(GetHandler(options).QueryInstances(options, namespaceName, queryDialect, queryExpression, keysOnly)); }