public void TestInitialize()
        {
            sourceModel = new BindingModel();
            targetModel = new BindingModel();

            sourceProp = sourceModel.GetPropertyRef(PropText);
            targetProp = targetModel.GetPropertyRef(PropText);
        }
        public void UnregisterProperty(RuntimeAddin addin, string targetType, string name)
        {
            TypeRef tr;

            if (!pendingTypesByTypeName.TryGetValue(targetType, out tr))
            {
                return;
            }

            if (tr.DataType != null)
            {
                Type t = addin.GetType(targetType, false);
                if (t != null)
                {
                    UnregisterProperty(t, name);
                }
                return;
            }

            PropertyRef prop = tr.Properties;
            PropertyRef prev = null;

            while (prop != null)
            {
                if (prop.Name == name)
                {
                    if (prev != null)
                    {
                        prev.Next = prop.Next;
                    }
                    else
                    {
                        tr.Properties = null;
                    }
                    break;
                }
                prev = prop;
                prop = prop.Next;
            }
        }
        protected PropertyRef?ReadPropertyRef()
        {
            using (this.Trace(nameof(PropertyRef)))
            {
                if (this.TryPrepareDeserializeReusableObject(out uint id, out PropertyRef? value))
                {
                    var declaringType = this.ReadTypeRef();
                    var propertyType  = this.ReadTypeRef();
                    var metadataToken = this.ReadCompressedMetadataToken(MetadataTokenType.Property);
                    var name          = this.ReadString();
                    var isStatic      = this.ReadCompressedUInt() != 0;

                    byte flags = this.reader.ReadByte();
                    int? getter = null, setter = null;
                    if ((flags & 0x1) != 0)
                    {
                        getter = this.ReadCompressedMetadataToken(MetadataTokenType.Method);
                    }

                    if ((flags & 0x2) != 0)
                    {
                        setter = this.ReadCompressedMetadataToken(MetadataTokenType.Method);
                    }

                    value = new PropertyRef(
                        declaringType,
                        propertyType,
                        metadataToken,
                        getter,
                        setter,
                        name,
                        isStatic);

                    this.OnDeserializedReusableObject(id, value);
                }

                return(value);
            }
        }
        protected void Write(PropertyRef propertyRef)
        {
            using (this.Trace("PropertyRef"))
            {
                this.Write(propertyRef.DeclaringType);
                this.WriteCompressedMetadataToken(propertyRef.MetadataToken, MetadataTokenType.Property);

                byte flags = 0;
                flags |= propertyRef.GetMethodMetadataToken.HasValue ? (byte)0x1 : (byte)0x0;
                flags |= propertyRef.SetMethodMetadataToken.HasValue ? (byte)0x2 : (byte)0x0;
                this.writer.Write(flags);

                if (propertyRef.GetMethodMetadataToken.HasValue)
                {
                    this.WriteCompressedMetadataToken(propertyRef.GetMethodMetadataToken.Value, MetadataTokenType.Method);
                }

                if (propertyRef.SetMethodMetadataToken.HasValue)
                {
                    this.WriteCompressedMetadataToken(propertyRef.SetMethodMetadataToken.Value, MetadataTokenType.Method);
                }
            }
        }
Example #5
0
        /// <summary>
        /// Automatically creates a reader for a field
        /// </summary>
        /// <returns>A <see cref="ClassMethod"/></returns>
        private ClassMethod CreateReader()
        {
            Block block = null;

            switch (Modifier)
            {
            case Modifier.Abstract:
                break;

            case Modifier.Static:
                var qName = new QualifiedName(Definer.Name, BackingFieldName);
                block = Block.Return(new StaticPropertyRef(qName));
                break;

            default:
                block = Block.Return(PropertyRef.This(BackingFieldName));
                break;
            }

            var function = new Function(Parameter.EmptyArray, block);

            return(new ClassMethod(GetReaderName(Name), ReaderScope, Modifier, function));
        }
        private static void CreateStorageAssociationReferentialConstraintProperties(LinqToEdmx.Model.Storage.Association association, IEnumerable <AssociationProperty> properties, bool isParentEntity)
        {
            //  <ReferentialConstraint>
            //      <Principal Role="Category">
            //          <PropertyRef Name="CategoryId" />
            //      </Principal>
            //      <Dependent Role="Product">
            //          <PropertyRef Name="CategoryId" />
            //      </Dependent>
            //  </ReferentialConstraint>
            foreach (var property in properties)
            {
                var principalProp = !isParentEntity ? property.Property : property.ForeignProperty;
                var dependentProp = !isParentEntity ? property.ForeignProperty : property.Property;

                var principalProperty = association.ReferentialConstraint.Principal.PropertyRefs.Where(p => p.Name == principalProp.KeyName).FirstOrDefault();
                if (principalProperty == null)
                {
                    principalProperty = new PropertyRef()
                    {
                        Name = principalProp.KeyName
                    };
                    association.ReferentialConstraint.Principal.PropertyRefs.Add(principalProperty);
                }

                var dependentProperty = association.ReferentialConstraint.Dependent.PropertyRefs.Where(p => p.Name == dependentProp.KeyName).FirstOrDefault();
                if (dependentProperty == null)
                {
                    dependentProperty = new PropertyRef()
                    {
                        Name = dependentProp.KeyName
                    };
                    association.ReferentialConstraint.Dependent.PropertyRefs.Add(dependentProperty);
                }
            }
        }
Example #7
0
 public void CompilePropertyRef(PropertyRef fieldRef)
 {
     MayBeParenthesize(fieldRef.Owner);
     textWriter.Write(".{0}", SafeName(fieldRef.PropertyName));
 }
 /// <summary>
 /// Create a nested property ref, with "p" as the prefix
 /// </summary>
 /// <param name="p">the property to prefix with</param>
 /// <returns>the nested property reference</returns>
 internal override PropertyRef CreateNestedPropertyRef(PropertyRef p)
 {
     return p;
 }
Example #9
0
        /// <summary>
        /// Recognizes composite expressions like those with a couple of brackets or a dot.
        /// </summary>
        /// <returns>An <see cref="ItemRef"/>, a <see cref="PropertyRef"/> or a <see cref="MethodCall"/></returns>
        protected Expression Composite()
        {
            Expression expr = Atom();

            if (expr == null)
            {
                return(null);
            }

            Token bookmark;
            bool  loop = true;

            while (loop)
            {
                SkipComments();
                switch (token.TokenID)
                {
                case TokenID.LeftBracket:
                {
                    Consume(1);
                    var index = Required <Expression>(Expression, Resources.ExpressionRequired);
                    bookmark = Match(TokenID.RightBracket);

                    Expression owner = expr;
                    expr = new ItemRef(owner, index);
                    expr.SetLocation(owner.Start, bookmark.End);
                }
                break;

                case TokenID.Dot:
                {
                    Consume(1);
                    bookmark = Match(TokenID.Identifier);
                    string memberName = bookmark.ToString();

                    Expression owner = expr;
                    if (TryMatch(TokenID.LeftParenthesis))
                    {
                        Consume(1);
                        Expression[] args = List <Expression>(Expression, false, null);
                        bookmark = Match(TokenID.RightParenthesis);
                        expr     = new MethodCall(owner, memberName, args);
                    }
                    else
                    {
                        expr = new PropertyRef(owner, memberName);
                    }

                    expr.SetLocation(owner.Start, bookmark.End);
                }
                break;

                case TokenID.LeftParenthesis:
                {
                    Consume(1);
                    Expression[] args = List <Expression>(Expression, false, null);
                    bookmark = Match(TokenID.RightParenthesis);
                    Expression callee = expr;
                    expr = new AnonymousCall(callee, args);
                    expr.SetLocation(callee.Start, bookmark.End);
                }
                break;

                default:
                    loop = false;
                    break;
                }
            }

            return(expr);
        }
Example #10
0
 internal override PropertyRef CreateNestedPropertyRef(PropertyRef p)
 {
     return(p);
 }
Example #11
0
        public virtual void VisitItem(Object item)
        {
            if (item == null)
            {
                return;
            }

            Module module = item as Module;

            if (module != null)
            {
                VisitModule(module);
                return;
            }
            Product product = item as Product;

            if (product != null)
            {
                VisitProduct(product);
                return;
            }
            Feature feature = item as Feature;

            if (feature != null)
            {
                VisitFeature(feature);
                return;
            }
            AdvtExecuteSequence advtExecuteSequence = item as AdvtExecuteSequence;

            if (advtExecuteSequence != null)
            {
                VisitAdvtExecuteSequence(advtExecuteSequence);
                return;
            }
            InstallUISequence installUISequence = item as InstallUISequence;

            if (installUISequence != null)
            {
                VisitInstallUISequence(installUISequence);
                return;
            }
            User user = item as User;

            if (user != null)
            {
                VisitUser(user);
                return;
            }
            Upgrade upgrade = item as Upgrade;

            if (upgrade != null)
            {
                VisitUpgrade(upgrade);
                return;
            }
            Directory directory = item as Directory;

            if (directory != null)
            {
                VisitDirectory(directory);
                return;
            }
            PropertyRef propertyRef = item as PropertyRef;

            if (propertyRef != null)
            {
                VisitPropertyRef(propertyRef);
                return;
            }
            WebSite webSite = item as WebSite;

            if (webSite != null)
            {
                VisitWebSite(webSite);
                return;
            }
            AdminUISequence adminUISequence = item as AdminUISequence;

            if (adminUISequence != null)
            {
                VisitAdminUISequence(adminUISequence);
                return;
            }
            CustomAction customAction = item as CustomAction;

            if (customAction != null)
            {
                VisitCustomAction(customAction);
                return;
            }
            DirectoryRef directoryRef = item as DirectoryRef;

            if (directoryRef != null)
            {
                VisitDirectoryRef(directoryRef);
                return;
            }
            AppId appId = item as AppId;

            if (appId != null)
            {
                VisitAppId(appId);
                return;
            }
            Media media = item as Media;

            if (media != null)
            {
                VisitMedia(media);
                return;
            }
            CustomTable customTable = item as CustomTable;

            if (customTable != null)
            {
                VisitCustomTable(customTable);
                return;
            }
            Condition condition = item as Condition;

            if (condition != null)
            {
                VisitCondition(condition);
                return;
            }
            SFPCatalog sFPCatalog = item as SFPCatalog;

            if (sFPCatalog != null)
            {
                VisitSFPCatalog(sFPCatalog);
                return;
            }
            UI ui = item as UI;

            if (ui != null)
            {
                VisitUI(ui);
                return;
            }
            FragmentRef fragmentRef = item as FragmentRef;

            if (fragmentRef != null)
            {
                VisitFragmentRef(fragmentRef);
                return;
            }
            Icon icon = item as Icon;

            if (icon != null)
            {
                VisitIcon(icon);
                return;
            }
            Property property = item as Property;

            if (property != null)
            {
                VisitProperty(property);
                return;
            }
            FeatureRef featureRef = item as FeatureRef;

            if (featureRef != null)
            {
                VisitFeatureRef(featureRef);
                return;
            }
            WebDirProperties webDirProperties = item as WebDirProperties;

            if (webDirProperties != null)
            {
                VisitWebDirProperties(webDirProperties);
                return;
            }
            ComplianceCheck complianceCheck = item as ComplianceCheck;

            if (complianceCheck != null)
            {
                VisitComplianceCheck(complianceCheck);
                return;
            }
            InstallExecuteSequence installExecuteSequence = item as InstallExecuteSequence;

            if (installExecuteSequence != null)
            {
                VisitInstallExecuteSequence(installExecuteSequence);
                return;
            }
            AdminExecuteSequence adminExecuteSequence = item as AdminExecuteSequence;

            if (adminExecuteSequence != null)
            {
                VisitAdminExecuteSequence(adminExecuteSequence);
                return;
            }
            Binary binary = item as Binary;

            if (binary != null)
            {
                VisitBinary(binary);
                return;
            }
            Group group = item as Group;

            if (group != null)
            {
                VisitGroup(group);
                return;
            }
            WebApplication webApplication = item as WebApplication;

            if (webApplication != null)
            {
                VisitWebApplication(webApplication);
                return;
            }
            ActionSequenceType actionSequenceType = item as ActionSequenceType;

            if (actionSequenceType != null)
            {
                VisitActionSequenceType(actionSequenceType);
                return;
            }
            ActionModuleSequenceType actionModuleSequenceType = item as ActionModuleSequenceType;

            if (actionModuleSequenceType != null)
            {
                VisitActionModuleSequenceType(actionModuleSequenceType);
                return;
            }
            BillboardAction billboardAction = item as BillboardAction;

            if (billboardAction != null)
            {
                VisitBillboardAction(billboardAction);
                return;
            }
            Error error = item as Error;

            if (error != null)
            {
                VisitError(error);
                return;
            }
            Dialog dialog = item as Dialog;

            if (dialog != null)
            {
                VisitDialog(dialog);
                return;
            }
            ProgressText progressText = item as ProgressText;

            if (progressText != null)
            {
                VisitProgressText(progressText);
                return;
            }
            TextStyle textStyle = item as TextStyle;

            if (textStyle != null)
            {
                VisitTextStyle(textStyle);
                return;
            }
            ListBox listBox = item as ListBox;

            if (listBox != null)
            {
                VisitListBox(listBox);
                return;
            }
            ListView listView = item as ListView;

            if (listView != null)
            {
                VisitListView(listView);
                return;
            }
            ComboBox comboBox = item as ComboBox;

            if (comboBox != null)
            {
                VisitComboBox(comboBox);
                return;
            }
            UIText uIText = item as UIText;

            if (uIText != null)
            {
                VisitUIText(uIText);
                return;
            }
            RadioGroup radioGroup = item as RadioGroup;

            if (radioGroup != null)
            {
                VisitRadioGroup(radioGroup);
                return;
            }
            IniFileSearch iniFileSearch = item as IniFileSearch;

            if (iniFileSearch != null)
            {
                VisitIniFileSearch(iniFileSearch);
                return;
            }
            RegistrySearch registrySearch = item as RegistrySearch;

            if (registrySearch != null)
            {
                VisitRegistrySearch(registrySearch);
                return;
            }
            ComponentSearch componentSearch = item as ComponentSearch;

            if (componentSearch != null)
            {
                VisitComponentSearch(componentSearch);
                return;
            }
            FileSearch fileSearch = item as FileSearch;

            if (fileSearch != null)
            {
                VisitFileSearch(fileSearch);
                return;
            }
            DirectorySearch directorySearch = item as DirectorySearch;

            if (directorySearch != null)
            {
                VisitDirectorySearch(directorySearch);
                return;
            }
            File file = item as File;

            if (file != null)
            {
                VisitFile(file);
                return;
            }
            Component component = item as Component;

            if (component != null)
            {
                VisitComponent(component);
                return;
            }
            Merge merge = item as Merge;

            if (merge != null)
            {
                VisitMerge(merge);
                return;
            }
            Custom custom = item as Custom;

            if (custom != null)
            {
                VisitCustom(custom);
                return;
            }
            WebError webError = item as WebError;

            if (webError != null)
            {
                VisitWebError(webError);
                return;
            }
            WebVirtualDir webVirtualDir = item as WebVirtualDir;

            if (webVirtualDir != null)
            {
                VisitWebVirtualDir(webVirtualDir);
                return;
            }
            WebDir webDir = item as WebDir;

            if (webDir != null)
            {
                VisitWebDir(webDir);
                return;
            }
            WebFilter webFilter = item as WebFilter;

            if (webFilter != null)
            {
                VisitWebFilter(webFilter);
                return;
            }
            MergeRef mergeRef = item as MergeRef;

            if (mergeRef != null)
            {
                VisitMergeRef(mergeRef);
                return;
            }
            Subscribe subscribe = item as Subscribe;

            if (subscribe != null)
            {
                VisitSubscribe(subscribe);
                return;
            }
            Publish publish = item as Publish;

            if (publish != null)
            {
                VisitPublish(publish);
                return;
            }
            TypeLib typeLib = item as TypeLib;

            if (typeLib != null)
            {
                VisitTypeLib(typeLib);
                return;
            }
            Shortcut shortcut = item as Shortcut;

            if (shortcut != null)
            {
                VisitShortcut(shortcut);
                return;
            }
            ODBCTranslator oDBCTranslator = item as ODBCTranslator;

            if (oDBCTranslator != null)
            {
                VisitODBCTranslator(oDBCTranslator);
                return;
            }
            Permission permission = item as Permission;

            if (permission != null)
            {
                VisitPermission(permission);
                return;
            }
            Class _class = item as Class;

            if (_class != null)
            {
                VisitClass(_class);
                return;
            }
            CopyFile copyFile = item as CopyFile;

            if (copyFile != null)
            {
                VisitCopyFile(copyFile);
                return;
            }
            Patch patch = item as Patch;

            if (patch != null)
            {
                VisitPatch(patch);
                return;
            }
            ODBCDriver oDBCDriver = item as ODBCDriver;

            if (oDBCDriver != null)
            {
                VisitODBCDriver(oDBCDriver);
                return;
            }
            PerfCounter perfCounter = item as PerfCounter;

            if (perfCounter != null)
            {
                VisitPerfCounter(perfCounter);
                return;
            }
            FileShare fileShare = item as FileShare;

            if (fileShare != null)
            {
                VisitFileShare(fileShare);
                return;
            }
            Certificate certificate = item as Certificate;

            if (certificate != null)
            {
                VisitCertificate(certificate);
                return;
            }
            Category category = item as Category;

            if (category != null)
            {
                VisitCategory(category);
                return;
            }
            WebAppPool webAppPool = item as WebAppPool;

            if (webAppPool != null)
            {
                VisitWebAppPool(webAppPool);
                return;
            }
            SqlString sqlString = item as SqlString;

            if (sqlString != null)
            {
                VisitSqlString(sqlString);
                return;
            }
            ServiceControl serviceControl = item as ServiceControl;

            if (serviceControl != null)
            {
                VisitServiceControl(serviceControl);
                return;
            }
            IsolateComponent isolateComponent = item as IsolateComponent;

            if (isolateComponent != null)
            {
                VisitIsolateComponent(isolateComponent);
                return;
            }
            ServiceConfig serviceConfig = item as ServiceConfig;

            if (serviceConfig != null)
            {
                VisitServiceConfig(serviceConfig);
                return;
            }
            WebProperty webProperty = item as WebProperty;

            if (webProperty != null)
            {
                VisitWebProperty(webProperty);
                return;
            }
            SqlScript sqlScript = item as SqlScript;

            if (sqlScript != null)
            {
                VisitSqlScript(sqlScript);
                return;
            }
            SqlDatabase sqlDatabase = item as SqlDatabase;

            if (sqlDatabase != null)
            {
                VisitSqlDatabase(sqlDatabase);
                return;
            }
            WebLockdown webLockdown = item as WebLockdown;

            if (webLockdown != null)
            {
                VisitWebLockdown(webLockdown);
                return;
            }
            Extension extension = item as Extension;

            if (extension != null)
            {
                VisitExtension(extension);
                return;
            }
            ReserveCost reserveCost = item as ReserveCost;

            if (reserveCost != null)
            {
                VisitReserveCost(reserveCost);
                return;
            }
            RemoveFile removeFile = item as RemoveFile;

            if (removeFile != null)
            {
                VisitRemoveFile(removeFile);
                return;
            }
            ProgId progId = item as ProgId;

            if (progId != null)
            {
                VisitProgId(progId);
                return;
            }
            Microsoft.Tools.WindowsInstallerXml.Serialize.Environment environment = item as
                                                                                    Microsoft.Tools.WindowsInstallerXml.Serialize.Environment;
            if (environment != null)
            {
                VisitEnvironment(environment);
                return;
            }
            ServiceInstall serviceInstall = item as ServiceInstall;

            if (serviceInstall != null)
            {
                VisitServiceInstall(serviceInstall);
                return;
            }
            IniFile iniFile = item as IniFile;

            if (iniFile != null)
            {
                VisitIniFile(iniFile);
                return;
            }
            Registry registry = item as Registry;

            if (registry != null)
            {
                VisitRegistry(registry);
                return;
            }
            CreateFolder createFolder = item as CreateFolder;

            if (createFolder != null)
            {
                VisitCreateFolder(createFolder);
                return;
            }
            MIME mIME = item as MIME;

            if (mIME != null)
            {
                VisitMIME(mIME);
                return;
            }
            Verb verb = item as Verb;

            if (verb != null)
            {
                VisitVerb(verb);
                return;
            }
        }
Example #12
0
 public virtual void VisitPropertyRef(PropertyRef node)
 {
 }
Example #13
0
		public void RegisterProperty (RuntimeAddin addin, string targetType, string name, string propertyType, bool isExternal, bool skipEmpty)
		{
			TypeRef tr;
			if (!pendingTypesByTypeName.TryGetValue (targetType, out tr)) {
				tr = new TypeRef (addin, targetType);
				pendingTypesByTypeName [targetType] = tr;
			}
			if (tr.DataType != null) {
				RegisterProperty (addin.GetType (targetType, true), name, addin.GetType (propertyType, true), isExternal, skipEmpty);
				return;
			}
			PropertyRef prop = new PropertyRef (addin, targetType, name, propertyType, isExternal, skipEmpty);
			if (tr.Properties == null)
				tr.Properties = prop;
			else {
				PropertyRef plink = tr.Properties;
				while (plink.Next != null)
					plink = plink.Next;
				plink.Next = prop;
			}
		}
Example #14
0
 /// <summary>
 ///     Deletes the passed in PropertyRef in a referential constraint
 /// </summary>
 /// <param name="property"></param>
 internal DeleteReferentialConstraintPropertyRefCommand(PropertyRef property)
     : base(property)
 {
 }