Ejemplo n.º 1
0
        /// <summary>
        ///     Searches for provided object in directory and resolves it to distinguished name.
        /// </summary>
        /// <param name="objectCls">The object class to search for.</param>
        /// <param name="returnValue">The format of the returned string.</param>
        /// <param name="objectName">The common name of the object to search for.</param>
        /// <param name="ldapDomain">The LDAP domain to search in.</param>
        /// <returns></returns>
        /// <remarks>http://www.codeproject.com/Articles/18102/Howto-Almost-Everything-In-Active-Directory-via-C</remarks>
        public static string GetObjectDistinguishedName(ObjectClass objectCls,
                                                        ReturnType returnValue, string objectName, string ldapDomain)
        {
            var distinguishedName = string.Empty;
            var connectionPrefix  = string.Format("LDAP://{0}", ldapDomain);

            using (var entry = new DirectoryEntry(connectionPrefix))
            {
                using (var mySearcher = new DirectorySearcher(entry))
                {
                    switch (objectCls)
                    {
                    case ObjectClass.User:
                        mySearcher.Filter = string.Format("(&(objectClass=user)(|(cn={0})(sAMAccountName={0})))",
                                                          objectName);
                        break;

                    case ObjectClass.Group:
                        mySearcher.Filter = string.Format("(&(objectClass=group)(|(cn={0})(dn={0})))", objectName);
                        break;

                    case ObjectClass.Computer:
                        mySearcher.Filter = string.Format("(&(objectClass=computer)(|(cn={0})(dn={0})))", objectName);
                        break;
                    }

                    var result = mySearcher.FindOne();

                    if (result == null)
                    {
                        throw new NullReferenceException
                                  ("unable to locate the distinguishedName for the object " +
                                  objectName + " in the " + ldapDomain + " domain");
                    }

                    var directoryObject = result.GetDirectoryEntry();

                    if (returnValue.Equals(ReturnType.DistinguishedName))
                    {
                        distinguishedName = string.Format("LDAP://{0}", directoryObject.Properties
                                                          ["distinguishedName"].Value);
                    }

                    if (returnValue.Equals(ReturnType.ObjectGuid))
                    {
                        distinguishedName = directoryObject.Guid.ToString();
                    }
                }
            }
            return(distinguishedName);
        }
Ejemplo n.º 2
0
        public static string GetObjectDistinguishedName(string objectName, ObjectClass objectCls = ObjectClass.user, ReturnType returnValue = ReturnType.distinguishedName)
        {
            DirectoryEntry directoryObject   = GetObjectDirectoryEntry(objectName, objectCls, returnValue);
            string         distinguishedName = String.Empty;

            if (returnValue.Equals(ReturnType.distinguishedName))
            {
                distinguishedName = directoryObject.Properties["distinguishedName"].Value.ToString();
            }
            if (returnValue.Equals(ReturnType.ObjectGUID))
            {
                distinguishedName = directoryObject.Guid.ToString();
            }
            return(distinguishedName);
        }
        /// <summary>
        /// Compares <paramref name="obj"/> to this instance.
        /// </summary>
        /// <param name="obj"><see langword="object"/> to compare.</param>
        /// <returns>True if equal, false if not.</returns>
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            if (!base.Equals(obj))
            {
                return(false);
            }
            InterLinqMethodInfo other = (InterLinqMethodInfo)obj;

            if (GenericArguments.Count != other.GenericArguments.Count)
            {
                return(false);
            }

            for (int i = 0; i < GenericArguments.Count; i++)
            {
                if (!GenericArguments[i].Equals(other.GenericArguments[i]))
                {
                    return(false);
                }
            }

            return(ReturnType.Equals(other.ReturnType));
        }
Ejemplo n.º 4
0
 bool EqualSignature(CallIndirect other)
 {
     if (IsInstance != other.IsInstance)
     {
         return(false);
     }
     if (HasExplicitThis != other.HasExplicitThis)
     {
         return(false);
     }
     if (CallingConvention != other.CallingConvention)
     {
         return(false);
     }
     if (ParameterTypes.Length != other.ParameterTypes.Length)
     {
         return(false);
     }
     for (int i = 0; i < ParameterTypes.Length; i++)
     {
         if (!ParameterTypes[i].Equals(other.ParameterTypes[i]))
         {
             return(false);
         }
     }
     return(ReturnType.Equals(other.ReturnType));
 }
Ejemplo n.º 5
0
 public bool IsCompatibleWith(BasicSignature other)
 {
     return(CallingConvention == other.CallingConvention &&
            ((ParameterTypes == null && other.ParameterTypes == null) ||
             ParameterTypes.SequenceEqual(other.ParameterTypes)) &&
            ReturnType.Equals(other.ReturnType));
 }
Ejemplo n.º 6
0
        ObjectFormulaTree IDerivationOperation.Derivation(ObjectFormulaTree tree, string s)
        {
            Double a    = 0;
            double val  = 0;
            bool   zero = false;

            if (ReturnType.Equals(a))
            {
                zero = true;
                if (s.Length == 1)
                {
                    if (symbol is Char)
                    {
                        if (s[0] == (char)symbol)
                        {
                            val  = 1;
                            zero = false;
                        }
                    }
                }
            }
            if (zero)
            {
                return(ElementaryRealConstant.RealZero);
            }
            ElementaryRealConstant op = new ElementaryRealConstant(val);

            return(new ObjectFormulaTree(op, new List <ObjectFormulaTree>()));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Builds an return message.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="returnValue"></param>
        /// <param name="correlationId"></param>
        /// <returns></returns>
        private MethodResultMessage CreateMethodReturn(ReturnType type, object returnValue, string correlationId)
        {
            MethodResult methodResult = new MethodResult();

            methodResult.Type = type;
            methodResult.Arg  = returnValue;

            if (returnValue == null)
            {
                methodResult.ClassName = "null";
            }
            else
            {
                if (!type.Equals(ReturnType.Exception))
                {
                    methodResult.ClassName = new LocalType(returnValue.GetType()).RemoteTypeFullName;
                }
                else
                {
                    methodResult.ClassName = returnValue.GetType().ToString();
                }
            }

            methodResult.MetaData = new Dictionary <string, string>();
            return(MethodResultMessage.CreateInstance(methodResult, correlationId));
        }
Ejemplo n.º 8
0
 public bool Equals(Delegate other)
 {
     return
         (Name.Equals(other.Name) &&
          Parameters.Equals(other.Parameters) &&
          ReturnType.Equals(other.ReturnType));
 }
Ejemplo n.º 9
0
        public override bool Equals(object obj)
        {
            if (!(obj is FunctionSymbol symbol))
            {
                return(false);
            }

            if (!Name.Equals(symbol.Name) || !ReturnType.Equals(symbol.ReturnType))
            {
                return(false);
            }

            if (Parameters.Length != symbol.Parameters.Length)
            {
                return(false);
            }

            for (int index = 0; index < Parameters.Length; index++)
            {
                if (!Parameters[index].Equals(symbol.Parameters[index]))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 10
0
        public bool IsEquivalent(TaskInfo otherTaskInfo)
        {
            if (otherTaskInfo == null)
            {
                throw new ArgumentException("otherTaskInfo must not be null");
            }

            if (Args.Length != otherTaskInfo.Args.Length)
            {
                return(false);
            }

            for (var i = 0; i < Args.Length; ++i)
            {
                if (!Args[i].Equals(otherTaskInfo.Args[i]))
                {
                    return(false);
                }
            }

            return(string.Equals(AssemblyName, otherTaskInfo.AssemblyName, StringComparison.Ordinal) &&
                   string.Equals(TypeName, otherTaskInfo.TypeName, StringComparison.Ordinal) &&
                   string.Equals(MethodName, otherTaskInfo.MethodName, StringComparison.Ordinal) &&
                   ReturnType.Equals(otherTaskInfo.ReturnType));
        }
Ejemplo n.º 11
0
 public bool Equals(MethodDeclaration compareNode)
 {
     return
         (compareNode != null &&
          ReturnType?.Equals(compareNode.ReturnType) != false &&
          SemanticReturnType?.Equals(compareNode.SemanticReturnType) != false &&
          base.Equals(compareNode));
 }
Ejemplo n.º 12
0
        // 傳入Domain User Account Name取得DN
        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);
        }
Ejemplo n.º 13
0
 public bool Equals(LambdaExpression compareNode)
 {
     return
         (compareNode != null &&
          LambdaType?.Equals(compareNode.LambdaType) != false &&
          ReturnType?.Equals(compareNode.ReturnType) != false &&
          SemanticProperties?.Equals(compareNode.SemanticProperties) != false &&
          base.Equals(compareNode));
 }
Ejemplo n.º 14
0
        public override bool Equals(object obj)
        {
            MBeanOperationInfo other = obj as MBeanOperationInfo;

            return(other != null &&
                   Name.Equals(other.Name) &&
                   Description.Equals(other.Description) &&
                   Descriptor.Equals(other.Descriptor) &&
                   ReturnType.Equals(other.ReturnType) &&
                   Impact.Equals(other.Impact) &&
                   Signature.SequenceEqual(other.Signature));
        }
Ejemplo n.º 15
0
        public bool Equals(Prototype other)
        {
            var result = ReturnType.Equals(other.ReturnType) && Parameters.Count.Equals(other.Parameters.Count);

            if (result)
            {
                for (var i = 0; i < Parameters.Count; i++)
                {
                    result = result && Parameters[i].Equals(other.Parameters[i]);
                }
            }
            return(result);
        }
Ejemplo n.º 16
0
        public bool Equals(Prototype other)
        {
            if (other == null)
            {
                return(false);
            }

            if (!ReturnType.Equals(other.ReturnType) || !Parameters.Count.Equals(other.Parameters.Count))
            {
                return(false);
            }

            return(!Parameters.Where((t, i) => !t.Equals(other.Parameters[i])).Any());
        }
Ejemplo n.º 17
0
        protected override bool LLEquals(SwiftType other)
        {
            var fn = other as SwiftBaseFunctionType;

            if (fn == null)
            {
                return(false);
            }
            if (Name != null)
            {
                Name.Equals(fn.Name);
            }
            return(MemberType == fn.MemberType && Parameters.Equals(fn.Parameters) &&
                   ReturnType.Equals(fn.ReturnType));
        }
Ejemplo n.º 18
0
        public override bool Equals(object obj)
        {
            var type = obj as FunctionType;

            if (type == null)
            {
                return(false);
            }

            if (ReturnType.Equals(type.ReturnType) == false)
            {
                return(false);
            }

            return(CheckArgs(type.Args));
        }
Ejemplo n.º 19
0
        //only compare return type, attributes and signature
        public override bool Equals(object other)
        {
            var otherNode = other as FunctionDefinitionNode;

            if (null == otherNode)
            {
                return(false);
            }

            bool equalSignature = EqualityComparer <ArgumentSignatureNode> .Default.Equals(Signature, otherNode.Signature) &&
                                  ReturnType.Equals(otherNode.ReturnType) &&
                                  Attributes.SequenceEqual(otherNode.Attributes);

            bool equalBody = FunctionBody.Equals(otherNode.FunctionBody);

            return(equalSignature && equalBody);
        }
Ejemplo n.º 20
0
        public bool Equals(IType other)
        {
            if (other is AnyType)
            {
                return(true);
            }

            if (!(other is IFunctionType f))
            {
                return(false);
            }

            var returnTypeMatches = ReturnType.Equals(f.ReturnType);

            var paramTypesMatches = Enumerable.SequenceEqual(ParameterTypes, f.ParameterTypes);

            return(returnTypeMatches && paramTypesMatches);
        }
Ejemplo n.º 21
0
 public override bool Equals(TSMemberDescription other)
 {
     if (ReadOnly != other.ReadOnly)
     {
         return(false);
     }
     if (Parameters?.Count != other.Parameters?.Count)
     {
         return(false);
     }
     if (!ReturnType.Equals(other.ReturnType))
     {
         return(false);
     }
     if (Parameters == null)
     {
         return(true);
     }
     return(Parameters.SequenceEqual(other.Parameters));
 }
Ejemplo n.º 22
0
        private bool Equals(CppFunctionType other)
        {
            if (base.Equals(other) && ReturnType.Equals(other.ReturnType))
            {
                if (Parameters.Count != other.Parameters.Count)
                {
                    return(false);
                }

                for (int i = 0; i < Parameters.Count; i++)
                {
                    var fromType  = Parameters[i].Type;
                    var otherType = other.Parameters[i].Type;
                    if (!fromType.Equals(otherType))
                    {
                        return(false);
                    }
                }

                return(true);
            }

            return(false);
        }
Ejemplo n.º 23
0
 public bool Equals(MethodData?other) => other != null && Name == other.Name && ReturnType.Equals(other.ReturnType) && Parameters.Count == other.Parameters.Count && Parameters.Select((p, i) => (p, i)).All(t => t.p.Equals(other.Parameters[t.i]));
Ejemplo n.º 24
0
        public bool TryFoldInto(TSMemberDescription destination)
        {
            if (!ReturnType.Equals(destination.ReturnType))
            {
                return(false);
            }
            if (Parameters == null ^ destination.Parameters == null)
            {
                return(false);
            }                                                                          //one is a property, the other is not

            if (Parameters == null)
            {
                return(true);
            }

            var corresponding = Parameters.Zip(destination.Parameters).ToList();
            var equalTypes    = corresponding.All((sourceP, destP) => sourceP.Value.Type.Equals(destP.Value.Type));

            if (equalTypes)   //if there is only one additional parameter, we can fold using optional (or a rest) parameter
            {
                var allPairs = Parameters.ZipLongest(destination.Parameters, (sourceP, destP) => (sourceP: sourceP, destP: destP)).ToList();
                switch (allPairs.Count - corresponding.Count)
                {
                case 0:
                    return(true);

                case var x when x > 1:
                    return(false);

                case 1:
                    var extra = allPairs.Last();
                    var(sourceName, sourceDescr) = extra.sourceP;
                    var(destName, destDescr)     = extra.destP;
                    if (sourceName.IsNullOrEmpty())       //extra parameter in destination
                    {
                        if (destDescr.ParameterType == Standard)
                        {
                            destDescr.ParameterType = Optional;
                        }
                    }
                    else         //extra parameter in source
                    {
                        if (sourceDescr.ParameterType == Standard)
                        {
                            sourceDescr.ParameterType = Optional;
                        }
                        destination.Parameters.Add(sourceName, sourceDescr);
                    }
                    return(true);
                }
            }

            // TODO it might be possible to fold a method with one differing type, and a rest parameter.
            if (Parameters.Values().Any(x => x.ParameterType == Rest) || destination.Parameters.Values().Any(x => x.ParameterType == Rest))
            {
                return(false);
            }

            /*if (Parameters.Count != destination.Parameters.Count) {
             *  return false;
             * } else if (Parameters.Values().SequenceEqual(destination.Parameters.Values())) {
             *  return true;
             * }*/

            var foldableMethod       = true;
            var unfoldableParameters = Parameters.Values().Zip(destination.Parameters.Values(), (sourceParam, destParam) => {
                if (!foldableMethod)
                {
                    return(null);
                }
                if (sourceParam.ParameterType != destParam.ParameterType)   //if "optionality" of corresponding parameters doesn't match
                {
                    foldableMethod = false;
                    return(null);
                }
                var alreadyIncludesType = false;
                if (destParam.Type is TSComposedType x && sourceParam.Type is TSComposedType y)
                {
                    alreadyIncludesType = y.Parts.Except(x.Parts).None();
                }
Ejemplo n.º 25
0
 public override bool Equals(object obj)
 {
     return(obj is CFunctionType o && ReturnType.Equals(o.ReturnType) && ParameterTypesEqual(o));
 }
Ejemplo n.º 26
0
 public bool IsReturnType(string fullyQualifiedMetadataName)
 {
     return(ReturnType.Equals(SemanticModel.GetTypeByMetadataName(fullyQualifiedMetadataName)));
 }
Ejemplo n.º 27
0
 private bool Equals(CppFunctionType other)
 {
     return(base.Equals(other) && ReturnType.Equals(other.ReturnType) && ParameterTypes.SequenceEqual(other.ParameterTypes));
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Compares <paramref name="obj"/> to this instance.
        /// </summary>
        /// <param name="obj"><see langword="object"/> to compare.</param>
        /// <returns>True if equal, false if not.</returns>
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            if (!base.Equals(obj))
            {
                return(false);
            }
            InterLinqMethodInfo other = (InterLinqMethodInfo)obj;

            if (GenericArguments.Count != other.GenericArguments.Count)
            {
                return(false);
            }

            return(!GenericArguments.Where((t, i) => !t.Equals(other.GenericArguments[i])).Any() && ReturnType.Equals(other.ReturnType));
        }
Ejemplo n.º 29
0
 /// <inheritdoc />
 public bool Equals(MethodDescriptor other) =>
 ReturnType.Equals(other.ReturnType) && Parameters.SequenceEqual(other.Parameters);