public virtual Dictionary <Guid, IntegrityCheck> EntityIntegrityCheck() { using (Mixins.OfType <CorruptMixin>().Any(c => c.Corrupt) ? Corruption.AllowScope() : null) { return(EntityIntegrityCheckBase()); } }
public Field GetField(MemberInfo member) { if (member is MethodInfo mi) { if (mi.IsGenericMethod && mi.GetGenericMethodDefinition().Name == "Mixin") { if (Mixins == null) { throw new InvalidOperationException("{0} has not mixins".FormatWith(this.Type.Name)); } return(Mixins.GetOrThrow(mi.GetGenericArguments().Single())); } } FieldInfo fi = member as FieldInfo ?? Reflector.FindFieldInfo(Type, (PropertyInfo)member); if (fi == null) { throw new InvalidOperationException("Field {0} not found on {1}".FormatWith(member.Name, Type)); } EntityField field = Fields.GetOrThrow(fi.Name, "Field {0} not found on schema"); return(field.Field); }
public Field TryGetField(MemberInfo member) { if (member is MethodInfo mi) { if (mi.IsGenericMethod && mi.GetGenericMethodDefinition().Name == "Mixin") { return(Mixins?.TryGetC(mi.GetGenericArguments().Single())); } return(null); } if (member is Type) { return(Mixins?.TryGetC((Type)member)); } FieldInfo fi = member as FieldInfo ?? Reflector.TryFindFieldInfo(Type, (PropertyInfo)member); if (fi == null) { return(null); } EntityField field = Fields.TryGetC(fi.Name); if (field == null) { return(null); } return(field.Field); }
protected override BuildPlan MakeConstructPlan(IEnumerable <MethodParameterInjectionPoint> injects) { var paramInjects = injects.GroupBy(x => x.Member) .Select(x => x.OrderBy(i => i.Position).ToArray()) .DefaultIfEmpty(new MethodParameterInjectionPoint[0]) .First(); if (Mixins.Any()) // todo: interceptors { return(context => { var paramVals = paramInjects.Select(p => p.GetValue(context)).ToArray(); var mixinObjects = (from mixin in Mixins let reference = Manager.GetReference(mixin, context, mixin.InterfaceTypes) from interfaceType in mixin.InterfaceTypes select new { interfaceType, reference }) .ToDictionary(x => x.interfaceType, x => x.reference); return CormoProxyGenerator.CreateMixins(Type, mixinObjects, paramVals); }); } return(context => { var paramVals = paramInjects.Select(p => p.GetValue(context)).ToArray(); return Activator.CreateInstance(Type, paramVals); }); }
public MixinBlock LookupMixin(string name, int lookupDepth = 0) { MixinBlock ret; if (Mixins.TryGetValue(name, out ret)) { return(ret); } if (lookupDepth > 100) { Current.RecordError(ErrorType.Compiler, InvocationSite, "Scope max depth exceeded, probably infinite recursion"); throw new StoppedCompilingException(); } Value var; if (Variables.TryGetValue(name, out var)) { var func = var as FuncValue; if (func != null) { return(LookupMixin(func.Name, lookupDepth + 1)); } } if (ParentScope != null) { return(ParentScope.LookupMixin(name, lookupDepth + 1)); } return(null); }
public override object Clone() { var newMixin = (ShaderMixinSource)MemberwiseClone(); newMixin.Compositions = Compositions == null ? null : ToSortedList(Compositions.Select(x => new KeyValuePair<string, ShaderSource>(x.Key, (ShaderSource)x.Value.Clone()))); newMixin.Mixins = Mixins == null ? null : Mixins.Select(x => (ShaderClassCode)x.Clone()).ToList(); newMixin.Macros = Macros == null ? null : new List<ShaderMacro>(Macros.ToArray()); return newMixin; }
public void AddMixin(Metadata mixin) { if (Mixins == null) { Mixins = new List <Metadata>(); } Mixins.Add(mixin); }
/// <summary> /// Returns a <see cref="T:System.String"></see> that represents the current <see cref="ClassContext"/>. /// </summary> /// <returns> /// A <see cref="T:System.String"></see> containing the type names of this context's associated <see cref="Type"/>, all its mixin types, and /// composed interfaces. /// </returns> public override string ToString() { return(string.Format( "ClassContext: '{0}'{1} Mixins: {2}{1} ComposedInterfaces: ({3})", Type, Environment.NewLine, string.Join("", Mixins.Select(mc => Environment.NewLine + " " + mc)), string.Join(",", ComposedInterfaces.Select(ifc => ifc.Name)))); }
public void FinishApplication() { if (IsSwc) { return; } Mixins.Import(); //ImportLateAssets(); }
/// <summary> /// Clones from the specified <see cref="ShaderMixinSource"/>. /// </summary> /// <param name="parent">The parent mixin to clone from.</param> /// <exception cref="System.ArgumentNullException">parent</exception> public void CloneFrom(ShaderMixinSource parent) { if (parent == null) throw new ArgumentNullException("parent", $"Cannot clone mixin [{Name}] from a null parent"); Mixins.AddRange(parent.Mixins); Macros.AddRange(parent.Macros); foreach (var shaderBasic in parent.Compositions) { Compositions[shaderBasic.Key] = shaderBasic.Value; } }
/// <summary> /// Clones from the specified <see cref="ShaderMixinSource"/>. Clones members too. /// </summary> /// <param name="parent">The parent mixin to clone from.</param> /// <exception cref="System.ArgumentNullException">parent</exception> public void DeepCloneFrom(ShaderMixinSource parent) { if (parent == null) throw new ArgumentNullException("parent", $"Cannot deep clone mixin [{Name}] from a null parent"); foreach (var mixin in parent.Mixins) Mixins.Add((ShaderClassCode)mixin.Clone()); Macros.AddRange(parent.Macros); foreach (var shaderBasic in parent.Compositions) { Compositions[shaderBasic.Key] = (ShaderSource)shaderBasic.Value.Clone(); } }
public static StyleSheet Parse(TextReader reader, CssContext?context = null) { var sheet = new StyleSheet(context ?? new CssContext()); IList <BrowserInfo>?browsers = null; using (var parser = new CssParser(reader)) { foreach (var node in parser.ReadNodes()) { if (node.Kind == NodeKind.Mixin) { var mixin = (MixinNode)node; sheet.Context !.Mixins.Add(mixin.Name, mixin); } else if (node.Kind == NodeKind.Directive) { var directive = (CssDirective)node; if (directive.Name == "support" && directive.Value != null) { string[] parts = directive.Value.Split(Seperators.Space); // SpaceArray... if (Enum.TryParse(parts[0].Trim(), true, out BrowserType browserType)) { if (browsers is null) { browsers = new List <BrowserInfo>(); } var browserVersion = float.Parse(parts[parts.Length - 1].Trim(trimBrowserChars)); browsers.Add(new BrowserInfo(browserType, browserVersion)); } } } else { sheet.AddChild(node); } } if (browsers != null) { sheet.Context !.SetCompatibility(browsers.ToArray()); } } return(sheet); }