protected internal override bool ValidateInitializer(IDefinitionInstallerContext installer) { if (installer == null) { throw new ArgumentNullException(); } // 2. Get the global. GlobalVariableOrConstantBinding globalBinding = installer.GetGlobalVariableOrConstantBinding(this.GlobalName.Value); ClassBinding classBinding = installer.GetClassBinding(this.GlobalName.Value); // 3. Check that such a binding exists ... but not both if (!((globalBinding == null) ^ (classBinding == null))) { return(installer.ReportError(this.GlobalName, InstallerErrors.GlobalInvalidName)); } if ((classBinding != null) && (classBinding.Value == null)) { throw new InvalidOperationException("Should have been set in ClassDefinition.CreataGlobalObject()."); } if (classBinding != null) { return(this.Factory.ValidateClassInitializer(this, classBinding.Value, installer, new IntermediateCodeValidationErrorSink(this.MethodSourceCodeService, installer))); } if (globalBinding.IsConstantBinding && globalBinding.HasBeenSet) { return(installer.ReportError(this.GlobalName, InstallerErrors.GlobalIsConstant)); } return(this.Factory.ValidateGlobalInitializer(this, installer, new IntermediateCodeValidationErrorSink(this.MethodSourceCodeService, installer))); }
public CompiledInitializer CreateInitializer(InitializerDefinition definition, IDefinitionInstallerContext installer) { GlobalVariableOrConstantBinding globalBinding = installer.GetGlobalVariableOrConstantBinding(this.GlobalName); ClassBinding classBinding = installer.GetClassBinding(this.GlobalName); // 3. Check that such a binding exists ... but not both if (!((globalBinding == null) ^ (classBinding == null))) { return(null); } if (classBinding != null) { return(new RuntimeGlobalInitializer(this.ParseTree, new DebugInfoService(this.SourceCodeService), classBinding)); } if (globalBinding != null) { return(new RuntimeGlobalInitializer(this.ParseTree, new DebugInfoService(this.SourceCodeService), globalBinding)); } return(null); }