public returnType rt; //возвращаемое значение public Meth(MethodInfo _m, string _name, string _desc, returnType r) { m = _m; name = _name; desc = _desc; rt = r; }
/// <summary> /// Returns MessagePack encoded into base64 /// </summary> public string getMP(List <c_DataObject> strs, returnType rettype) { List <byte> bb = new List <byte>(); StringBuilder ret = new StringBuilder(); byte[] b = new byte[] { 0 }; if (strs.Count > 1) { b = MessagePackSerializer.Serialize(strs); } else if (strs.Count == 1) { b = MessagePackSerializer.Serialize(strs[0]); } bb.AddRange(b); switch (rettype) { case returnType.hexadecimal_string: foreach (byte b_ in bb) { ret.Append(b_.ToString("X2") + " "); } break; case returnType.decimal_string: foreach (byte b_ in bb) { ret.Append(((int)b_).ToString() + " "); } break; case returnType.octal_string: foreach (byte b_ in bb) { ret.Append((Convert.ToString(b_, 8)).ToString() + " "); } break; case returnType.bytes: foreach (byte b_ in bb) { ret.Append((char)b_); } break; default: case returnType.base64_string: ret.Append(Convert.ToBase64String((bb.ToArray()))); break; } return(ret.ToString().Trim()); }
public static string GetObjectDistinguishedName(objectClass objectCls, returnType returnValue, string objectName, string LdapDomain) { string distinguishedName = string.Empty; string connectionPrefix = "LDAP://" + LdapDomain; DirectoryEntry entry = new DirectoryEntry(connectionPrefix); DirectorySearcher mySearcher = new DirectorySearcher(entry); switch (objectCls) { case objectClass.user: mySearcher.Filter = "(&(objectClass=user)(|(cn=" + objectName + ")(sAMAccountName=" + objectName + ")))"; break; case objectClass.group: mySearcher.Filter = "(&(objectClass=group)(|(cn=" + objectName + ")(dn=" + objectName + ")))"; break; case objectClass.computer: mySearcher.Filter = "(&(objectClass=computer)(|(cn=" + objectName + ")(dn=" + objectName + ")))"; break; } SearchResult result = mySearcher.FindOne(); if (result == null) { throw new NullReferenceException ("unable to locate the distinguishedName for the object " + objectName + " in the " + LdapDomain + " domain"); } DirectoryEntry directoryObject = result.GetDirectoryEntry(); if (returnValue.Equals(returnType.distinguishedName)) { distinguishedName = "LDAP://" + directoryObject.Properties ["distinguishedName"].Value; } if (returnValue.Equals(returnType.ObjectGUID)) { distinguishedName = directoryObject.Guid.ToString(); } entry.Close(); entry.Dispose(); mySearcher.Dispose(); return(distinguishedName); }
public string toString(returnType type = returnType.plain) { switch (type) { case returnType.plain: break; case returnType.json: break; case returnType.xml: break; case returnType.blocked: break; case returnType.newlines: break; } return(""); }
=> Type = new IntrinsicFunctionType(returnType, parameterCount, DoesParameterTypeMatch);
internal static string GetObjectDistinguishedName(objectClass objectCls, returnType returnValue, string objectName, string LdapDomain) { string distinguishedName = string.Empty; string connectionPrefix = "LDAP://" + LdapDomain; DirectoryEntry entry = Utility.NewDirectoryEntry(connectionPrefix); DirectorySearcher mySearcher = new DirectorySearcher(entry); switch (objectCls) { case objectClass.user: mySearcher.Filter = "(&(objectClass=user)(|(cn=" + objectName + ")(sAMAccountName=" + objectName + ")))"; break; case objectClass.group: mySearcher.Filter = "(&(objectClass=group)(|(cn=" + objectName + ")(dn=" + objectName + ")))"; break; } SearchResult result = mySearcher.FindOne(); if (result == null) { throw new NullReferenceException("unable to locate the distinguishedName for the object " + objectName + " in the " + LdapDomain + " domain"); } DirectoryEntry directoryObject = result.GetDirectoryEntry(); if (returnValue.Equals(returnType.distinguishedName)) { distinguishedName = "LDAP://" + directoryObject.Properties["distinguishedName"].Value; } if (returnValue.Equals(returnType.ObjectGUID)) { distinguishedName = directoryObject.Guid.ToString(); } entry.Close(); entry.Dispose(); mySearcher.Dispose(); return distinguishedName; }
public static object RunProcedure(string storedProcName, OracleParameter[] parameters, returnType rt) { OracleConnection conn = pool.fetchConnection(); object res = null; switch (rt) { case returnType.rvoid: OracleHelper.RunProcedure(conn, storedProcName, parameters); break; case returnType.rint: res = OracleHelper.RunProcedureInt(conn, storedProcName, parameters); break; case returnType.rbool: res = OracleHelper.RunProcedureBool(conn, storedProcName, parameters); break; } pool.releaseConnection(conn); return(res); }
// Step 2: submitRequest() // Submits the SOAP request defined in the SMSTest object to the SMS web service for processing. private Result submitRequest() { // l submitRequestType requestType = null; returnType returnT = null; Result result = null; // We track whether a fault was raised, because it affects whether we copy session info from the response header later faultRaised = false; // Send the SOAP request to SMS running on the AES server String mType = WEB_REFERENCE_NAMESPACE + "." + model + "Type"; try { // Try to create model type Type modelType = Type.GetType(mType, true); // true fail on error - model doesnt exist! object[] modelArray = new object[1]; modelArray[0] = System.Activator.CreateInstance(modelType); // Populate Fields modelArray[0] = populateFields(modelArray[0]); requestType = new submitRequestType(); requestType.modelFields = new modelChoices(); requestType.modelFields.Items = modelArray; requestType.objectname = objectname; // objectname, not presently used requestType.operation = operation; requestType.qualifier = qualifier; returnT = sms.submitRequest(requestType); result = returnT.@return; } catch (TypeLoadException tle) { log.Info("ModelType: " + mType + " could not be loaded! Please verify this is a valid model."); log.Info(tle.Message); log.Info(tle.StackTrace); faultRaised = true; } catch (SoapException soapE) { // A fault was raised. The fault message will contain the explanation if (soapE.Message != null) { log.Info("Code: " + soapE.Code.Name); } if (soapE.Message != null) { log.Info("Message: " + soapE.Message); } if (soapE.Detail != null) { log.Info("Detail: " + soapE.Detail.InnerXml); } log.Info("A SOAP fault was raised: "); log.Info(soapE.Message); log.Info(soapE.StackTrace); faultRaised = true; } catch (Exception re) { // A fault was raised. The fault message will contain the explanation log.Info("An unexpected Exception was raised: "); log.Info(re.Message); log.Info(re.StackTrace); faultRaised = true; } // If we got a result (not a fault) then we'll show it if (!faultRaised) { // The result code indicates success or failure (CM rejected the request) if (result.result_code == 0) { log.Info("The request was successful (result_code == 0)"); modelChoices mc = result.result_data; // How many items were returned int resultLength = mc.Items.Length; if (resultLength > 0) { // We'll use a routine to illustrate processing the return values //prettyPrint(mc); } } else { faultRaised = true; // In case CM rejected the request, the message text will contain CM's explanation log.Info("The request returned an error (result_code == " + result.result_code + ")"); log.Info("result_data == " + '"' + result.result_data.Items + '"'); log.Info("message_text == " + result.message_text); } } return(result); }
=> new MethodRefBuilder(module, typeRef, FindMethod(typeRef, methodName, genericArity, returnType, paramTypes ?? throw new ArgumentNullException(nameof(paramTypes))));
public string GetObjectDistinguishedName(objectClass objectCls, returnType returnValue, string objectName, string ldapDomain, LogFile log) { // LdapDomain = "DC=Fabrikam,DC=COM" string distinguishedName = string.Empty; string connectionPrefix = "LDAP://" + ldapDomain; try { DirectoryEntry entry = new DirectoryEntry(connectionPrefix); DirectorySearcher mySearcher = new DirectorySearcher(entry); switch (objectCls) { case objectClass.user: mySearcher.Filter = "(&(objectClass=user)(|(CN=" + objectName + ")(sAMAccountName=" + objectName + ")))"; break; case objectClass.group: mySearcher.Filter = "(&(objectClass=group)(|(CN=" + objectName + ")(dn=" + objectName + ")))"; break; case objectClass.computer: mySearcher.Filter = "(&(objectClass=computer)(|(CN=" + objectName + ")(dn=" + objectName + ")))"; break; case objectClass.organizationalunit: mySearcher.Filter = "(&(objectClass=organizationalunit)(distinguishedname=" + objectName + "))"; break; } SearchResult result = mySearcher.FindOne(); if (result == null) { //throw new NullReferenceException //("unable to locate the distinguishedName for the object " + //objectName + " in the " + LdapDomain + " domain"); return string.Empty; } DirectoryEntry directoryObject = result.GetDirectoryEntry(); if (returnValue.Equals(returnType.distinguishedName)) { distinguishedName = "LDAP://" + directoryObject.Properties ["distinguishedName"].Value; } if (returnValue.Equals(returnType.ObjectGUID)) { distinguishedName = directoryObject.Guid.ToString(); } entry.Close(); entry.Dispose(); mySearcher.Dispose(); } catch (Exception ex) { log.addTrn("searcher failed " + ldapDomain + " " + objectName + " Exception " + ex.Message.ToString() + "\n" + ex.StackTrace.ToString(), "Error"); } return distinguishedName; }
private String GetObjectDistinguishedName(returnType returnValue, string objectName, string LdapDomain) { string distinguishedName = string.Empty; string connectionPrefix = "LDAP://" + LdapDomain; DirectoryEntry entry = new DirectoryEntry(connectionPrefix); DirectorySearcher mySearcher = new DirectorySearcher(entry); SearchResult result = null; mySearcher.Filter = "(&(objectClass=user)(|(cn=" + objectName + ")(sAMAccountName=" + objectName + ")))"; if (objectName != null || objectName != String.Empty) { result = mySearcher.FindOne(); } if (result != null) { DirectoryEntry directoryObject = result.GetDirectoryEntry(); if (returnValue.Equals(returnType.distinguishedName)) { distinguishedName = "LDAP://" + directoryObject.Properties ["distinguishedName"].Value; } if (returnValue.Equals(returnType.ObjectGUID)) { distinguishedName = directoryObject.Guid.ToString(); } } entry.Close(); entry.Dispose(); mySearcher.Dispose(); return distinguishedName; }