Thinktecture.Tools.Web.Services.CodeGeneration.AttributableCodeDomObject.SyncSourceAttributes C# (CSharp) Method

SyncSourceAttributes() private static method

private static SyncSourceAttributes ( CodeAttributeDeclaration source, CodeAttributeDeclaration destination ) : void
source System.CodeDom.CodeAttributeDeclaration
destination System.CodeDom.CodeAttributeDeclaration
return void
        private static void SyncSourceAttributes(CodeAttributeDeclaration source, CodeAttributeDeclaration destination)
        {
            Debug.Assert(source != null, "source parameter could not be null.");
            Debug.Assert(destination != null, "destination parameter could not be null.");

            // Process all arguments in the destination attribute.
            foreach (CodeAttributeArgument dstArg in destination.Arguments)
            {
                bool argumentFound = false;
                CodeAttributeArgumentExtended extDstArg = dstArg as CodeAttributeArgumentExtended;

                // Lookup all attribute arguments in the source to see if we can find a matching
                // argument.
                foreach (CodeAttributeArgument srcArg in source.Arguments)
                {
                    // Can we access the argument with our extended type pointer?
                    // Then use it to match empty argument names generated for
                    // default arguments.
                    if (extDstArg != null)
                    {
                        if ((string.Compare(srcArg.Name, extDstArg.Name, true) == 0) ||
                            (extDstArg.Default && srcArg.Name == ""))
                        {
                            // We've found the argument.
                            argumentFound = true;
                            // Sync value.
                            srcArg.Value = extDstArg.Value;
                            break;
                        }
                    }
                    else
                    {
                        if (string.Compare(srcArg.Name, dstArg.Name, true) == 0)
                        {
                            // We've found the argument.
                            argumentFound = true;
                            // Sync value.
                            srcArg.Value = dstArg.Value;
                            break;
                        }
                    }
                }

                // Add the argument if we haven't found it yet.
                if (!argumentFound)
                {
                    source.Arguments.Add(dstArg);
                }
            }
        }