Example #1
0
        private static void GetTypePrint(string typeName, Dictionary <Type, Dictionary <string, XmlAttributes> > attributes, StringBuilder printBuilder)
        {
            Type t = Type.GetType(typeName);
            Dictionary <string, XmlAttributes> memberAttributes = attributes[t];

            System.Diagnostics.Debug.Assert(null != memberAttributes);
            if (null == memberAttributes)
            {
                return;
            }

            var sorter = new StringSorter();

            foreach (string memberName in memberAttributes.Keys)
            {
                sorter.AddString(memberName);
            }
            string[] sortedMemberNames = sorter.GetOrderedArray();

            foreach (string memberName in sortedMemberNames)
            {
                printBuilder.AppendFormat("**{0}**", memberName);
                System.Diagnostics.Debug.WriteLine(string.Format("++ Started member thumbprint for type {0}, member:{1}.", typeName, memberName));
                GetXmlAttributesThumbprint(memberAttributes[memberName] as XmlAttributes, printBuilder);
                printBuilder.Append("***");
                System.Diagnostics.Debug.WriteLine(string.Format("-- Finished member thumbprint for type {0}, member:{1}.", typeName, memberName));
            }
        }
		public void SortStrings3()
		{
			StringSorter sorter = new StringSorter();
			sorter.AddString(s1);
			sorter.AddString(s2);
			sorter.AddString(s3);

			AssertStringOrder(sorter.GetOrderedArray());
		}
Example #3
0
        private static string GetClassThumbprint(XmlAttributeOverrides overrides)
        {
            Dictionary <Type, Dictionary <string, XmlAttributes> > types = GetTypesHashtable(overrides);
            // Types are the most significant information
            // in the key ... that why the type info comes first

            // what does the thumbprint of an XmlAttributeOverrides need to
            // consist of?
            // Type names are the key of the outer hashtable
            // The values of the outer hashtable are more hashtables
            // The keys of the inner hashtables are member names. The
            // values of the inner hashtable are XmlAttributes objects.
            // I.e. to create a content-based thumbprint of an
            // XmlAttributeOverrides we need to normalize first the
            // type names, then the member names and finally include the
            // values of each XmlAttributes object in the thumbprint.

            // so my first attempt at a thumbprint looks like this:
            // typeName:memberName:attributes:memberName:attributes:...
            // memberNames are orders alphabetically

            // the complete thumbprint for the XmlAttributeOverrides
            // concatenates the individual thumbrprints for a type in
            // the alphabetical order of the type names.

            var sorter = new StringSorter();

            foreach (Type t in types.Keys)
            {
                sorter.AddString(t.AssemblyQualifiedName);
            }
            string[] sortedTypeNames = sorter.GetOrderedArray();

            // now we have the types for which we have overriding attributes
            // in alphabetical order

            // TODO
            // Now generate thumbprint for each member of
            // each type
            var printBuilder = new StringBuilder();

            foreach (string typeName in sortedTypeNames)
            {
                System.Diagnostics.Debug.WriteLine(string.Format("+++ Starting thumbprint for type {0}", typeName));
                printBuilder.AppendFormat(">>{0}>>", typeName);
                GetTypePrint(typeName, types, printBuilder);
                printBuilder.Append("<<");
                System.Diagnostics.Debug.WriteLine(string.Format("--- Finished thumbprint for type {0}", typeName));
            }
            return(printBuilder.ToString());
        }
		private static string GetClassThumbprint(XmlAttributeOverrides overrides)
		{
			Hashtable types = GetTypesHashtable(overrides);
			// Types are the most significant information
			// in the key ... that why the type info comes first

			// what does the thumbprint of an XmlAttributeOverrides need to
			// consist of?
			// Type names are the key of the outer hashtable
			// The values of the outer hashtable are more hashtables
			// The keys of the inner hashtables are member names. The
			// values of the inner hashtable are XmlAttributes objects.
			// I.e. to create a content-based thumbprint of an 
			// XmlAttributeOverrides we need to normalize first the
			// type names, then the member names and finally include the
			// values of each XmlAttributes object in the thumbprint.

			// so my first attempt at a thumbprint looks like this:
			// typeName:memberName:attributes:memberName:attributes:...
			// memberNames are orders alphabetically
			
			// the complete thumbprint for the XmlAttributeOverrides
			// concatenates the individual thumbrprints for a type in
			// the alphabetical order of the type names.

			StringSorter sorter = new StringSorter();
			foreach (Type t in types.Keys)
			{
				sorter.AddString(t.AssemblyQualifiedName);
			}
			string[] sortedTypeNames = sorter.GetOrderedArray();
			
			// now we have the types for which we have overriding attributes 
			// in alphabetical order

			// TODO
			// Now generate thumbprint for each member of
			// each type
			StringBuilder printBuilder = new StringBuilder();

			foreach (string typeName in sortedTypeNames)
			{
				System.Diagnostics.Debug.WriteLine(string.Format("+++ Starting thumbprint for type {0}", typeName));
				printBuilder.AppendFormat(">>{0}>>", typeName);
				GetTypePrint(typeName, types, printBuilder);
				printBuilder.Append("<<");
				System.Diagnostics.Debug.WriteLine(string.Format("--- Finished thumbprint for type {0}", typeName));
			}
			return printBuilder.ToString();

		}
        /// <summary>
        /// Creates a signature for the passed in Type array. The order
        /// of the elements in the array does not influence the signature.
        /// </summary>
        /// <param name="types"></param>
        /// <returns>An instance indpendent signature of the Type array</returns>
        public static string GetTypeArraySignature(Type[] types)
        {
            if (null == types || types.Length <= 0)
            {
                return(null);
            }

            // to make sure we don't account for the order
            // of the types in the array, we create one SortedList
            // with the type names, concatenate them and hash that.
            var sorter = new StringSorter();

            foreach (Type t in types)
            {
                sorter.AddString(t.AssemblyQualifiedName);
            }

            return(string.Join(":", sorter.GetOrderedArray()));
        }
Example #6
0
        /// <summary>
        /// Creates a signature for the passed in Type array. The order
        /// of the elements in the array does not influence the signature.
        /// </summary>
        /// <param name="types"></param>
        /// <returns>An instance indpendent signature of the Type array</returns>
        public static string GetTypeArraySignature(Type[] types)
        {
            string thumbPrint = null;

            if (null != types && types.Length > 0)
            {
                StringBuilder typeNames = new StringBuilder();
                // to make sure we don't account for the order
                // of the types in the array, we create one SortedList
                // with the type names, concatenate them and hash that.
                StringSorter sorter = new StringSorter();
                foreach (Type t in types)
                {
                    sorter.AddString(t.AssemblyQualifiedName);
                }
                thumbPrint = string.Join(":", sorter.GetOrderedArray());
            }
            return(thumbPrint);
        }
Example #7
0
		/// <summary>
		/// Creates a signature for the passed in Type array. The order
		/// of the elements in the array does not influence the signature.
		/// </summary>
		/// <param name="types"></param>
		/// <returns>An instance indpendent signature of the Type array</returns>
		public static string GetTypeArraySignature(Type[] types)
		{
			string thumbPrint = null;
			if (null != types && types.Length > 0)
			{
				StringBuilder typeNames = new StringBuilder();
				// to make sure we don't account for the order
				// of the types in the array, we create one SortedList 
				// with the type names, concatenate them and hash that.
				StringSorter sorter = new StringSorter();
				foreach (Type t in types)
				{
					sorter.AddString(t.AssemblyQualifiedName);
				}
				thumbPrint = string.Join(":", sorter.GetOrderedArray());
			}
			return thumbPrint;
		}
		private static void GetTypePrint(string typeName, Hashtable attributes, StringBuilder printBuilder)
		{
			Type t = Type.GetType(typeName);
			Hashtable memberAttributes = attributes[t] as Hashtable;
			System.Diagnostics.Debug.Assert(null != memberAttributes);
			StringSorter sorter = new StringSorter();
			foreach (string memberName in memberAttributes.Keys)
			{
				sorter.AddString(memberName);
			}
			string[] sortedMemberNames = sorter.GetOrderedArray();
		
			foreach (string memberName in sortedMemberNames)
			{
				printBuilder.AppendFormat("**{0}**", memberName);
				System.Diagnostics.Debug.WriteLine(string.Format("++ Started member thumbprint for type {0}, member:{1}.", typeName, memberName));
				GetXmlAttributesThumbprint(memberAttributes[memberName] as XmlAttributes, printBuilder);
				printBuilder.Append("***");
				System.Diagnostics.Debug.WriteLine(string.Format("-- Finished member thumbprint for type {0}, member:{1}.", typeName, memberName));
			}
		}