private JsExpression GetScriptType(IType type, TypeContext typeContext, IRuntimeContext context) { if (type.Kind == TypeKind.Delegate) { return CreateTypeReferenceExpression(KnownTypeReference.Delegate); } else if (type is ParameterizedType) { var pt = (ParameterizedType)type; var def = pt.GetDefinition(); var sem = _metadataImporter.GetTypeSemantics(def); if (sem.Type == TypeScriptSemantics.ImplType.NormalType && !sem.IgnoreGenericArguments) return JsExpression.Invocation(JsExpression.Member(CreateTypeReferenceExpression(_systemScript), "makeGenericType"), CreateTypeReferenceExpression(type.GetDefinition()), JsExpression.ArrayLiteral(pt.TypeArguments.Select(a => GetScriptType(a, TypeContext.GenericArgument, context)))); else return GetTypeDefinitionScriptType(type.GetDefinition(), typeContext); } else if (type.TypeParameterCount > 0) { // This handles open generic types ( typeof(C<,>) ) return CreateTypeReferenceExpression(type.GetDefinition()); } else if (type.Kind == TypeKind.Array) { return CreateTypeReferenceExpression(KnownTypeReference.Array); } else if (type is ITypeParameter) { return context.ResolveTypeParameter((ITypeParameter)type); } else if (type is ITypeDefinition) { return GetTypeDefinitionScriptType((ITypeDefinition)type, typeContext); } else if (type.Kind == TypeKind.Anonymous || type.Kind == TypeKind.Null || type.Kind == TypeKind.Dynamic) { return CreateTypeReferenceExpression(KnownTypeReference.Object); } else { throw new InvalidOperationException("Could not determine the script type for " + type + ", context " + typeContext); } }
public WpfCleanWiringContextBuilder() { var xamlNamespaceRegistry = CreateXamlNamespaceRegistry(); TypeContext = new TypeContext(new WpfXamlTypeRepository(xamlNamespaceRegistry), xamlNamespaceRegistry, new TypeFactory()); ContentPropertyProvider = new WpfContentPropertyProvider(); TypeConverterProvider = new WpfTypeConverterProvider(); }
public static MvcHtmlString RenderPopup(HtmlHelper helper, TypeContext typeContext, RenderPopupMode mode, EntityBase line, bool isTemplate = false) { TypeContext tc = TypeContextUtilities.CleanTypeContext((TypeContext)typeContext); ViewDataDictionary vdd = GetViewData(helper, line, tc); string partialViewName = line.PartialViewName ?? OnPartialViewName(tc); vdd[ViewDataKeys.PartialViewName] = partialViewName; vdd[ViewDataKeys.ViewMode] = !line.ReadOnly; vdd[ViewDataKeys.ViewMode] = ViewMode.View; vdd[ViewDataKeys.ShowOperations] = true; vdd[ViewDataKeys.SaveProtected] = OperationLogic.IsSaveProtected(tc.UntypedValue.GetType()); vdd[ViewDataKeys.WriteEntityState] = !isTemplate && !(tc.UntypedValue is EmbeddedEntity) && ((ModifiableEntity)tc.UntypedValue).Modified == ModifiedState.SelfModified; switch (mode) { case RenderPopupMode.Popup: return helper.Partial(Navigator.Manager.PopupControlView, vdd); case RenderPopupMode.PopupInDiv: return helper.Div(typeContext.Compose(EntityBaseKeys.Entity), helper.Partial(Navigator.Manager.PopupControlView, vdd), "", new Dictionary<string, object> { { "style", "display:none" } }); default: throw new InvalidOperationException(); } }
private RuntimeFatMethodParameterInfo(MethodBase member, MethodHandle methodHandle, int position, ParameterHandle parameterHandle, ReflectionDomain reflectionDomain, MetadataReader reader, Handle typeHandle, TypeContext typeContext) : base(member, position, reflectionDomain, reader, typeHandle, typeContext) { _methodHandle = methodHandle; _parameterHandle = parameterHandle; _parameter = parameterHandle.GetParameter(reader); }
public static MvcHtmlString RenderContent(HtmlHelper helper, TypeContext typeContext, RenderContentMode mode, EntityBase line) { TypeContext tc = TypeContextUtilities.CleanTypeContext((TypeContext)typeContext); ViewDataDictionary vdd = GetViewData(helper, line, tc); string partialViewName = line.PartialViewName ?? OnPartialViewName(tc); switch (mode) { case RenderContentMode.Content: return helper.Partial(partialViewName, vdd); case RenderContentMode.ContentInVisibleDiv: return helper.Div(typeContext.Compose(EntityBaseKeys.Entity), helper.Partial(partialViewName, vdd), "", null); case RenderContentMode.ContentInInvisibleDiv: return helper.Div(typeContext.Compose(EntityBaseKeys.Entity), helper.Partial(partialViewName, vdd), "", new Dictionary<string, object> { { "style", "display:none" } }); default: throw new InvalidOperationException(); } }
public void ShouldSupportNumberTypes() { var inputTypes = new [] { typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(decimal), typeof(double) }; var context = new TypeContext(new Settings()); var expectedType = typeof(NumberType); foreach (var type in inputTypes) { var resolvedType = context.GetTypeScriptType(type.FullName); Assert.IsInstanceOfType(resolvedType, expectedType); } }
protected RuntimeMethodParameterInfo(MethodBase member, int position, ReflectionDomain reflectionDomain, MetadataReader reader, Handle typeHandle, TypeContext typeContext) : base(member, position) { _reflectionDomain = reflectionDomain; Reader = reader; _typeHandle = typeHandle; _typeContext = typeContext; }
public void GenerateTestMethods_TypeContainingProtectedMethodGiven() { var context = new TypeContext(typeof(TestAssembly.ProtectedConstructor), false); var result = testee.GenerateTestMethods(context); result.Should().NotBeNull(); result.Should().BeEmpty(); }
public CleanWiringContextBuilder(ITypeFactory factory) { var xamlNamespaceRegistry = CreateXamlNamespaceRegistry(); var typeFactory = factory; TypeContext = new TypeContext(new XamlTypeRepository(xamlNamespaceRegistry, typeFactory), xamlNamespaceRegistry, typeFactory); ContentPropertyProvider = new ContentPropertyProvider(); TypeConverterProvider = new TypeConverterProvider(); }
public void GenerateTestMethods_ProtectedConstructorTypeGiven_ShouldNotReturnAnyTestMethod() { var context = new TypeContext(typeof(TestAssembly.ProtectedConstructor), false); var result = testee.GenerateTestMethods(context); result.Should().NotBeNull(); result.Should().BeEmpty(); }
public void GenerateTestMethods_TypeWithOverloadsGiven() { var context = new TypeContext(typeof(TestAssembly.OverloadedMethods), true); var result = testee.GenerateTestMethods(context); result.Should().NotBeNull(); result.Should().OnlyContain(x => x.Name == expectedMethodName); result.Should().OnlyContain(x => x.SourceCode == expectedSourceCode); }
/// <summary> /// See <see cref="IReferenceResolver.GetReferences"/> /// </summary> /// <param name="context"></param> /// <param name="includeAssemblies"></param> /// <returns></returns> public IEnumerable<CompilerReference> GetReferences(TypeContext context = null, IEnumerable<CompilerReference> includeAssemblies = null) { return CompilerServicesUtility .GetLoadedAssemblies() .Where(a => !a.IsDynamic && File.Exists(a.Location) && !a.Location.Contains(CompilerServiceBase.DynamicTemplateNamespace)) .GroupBy(a => a.GetName().Name).Select(grp => grp.First(y => y.GetName().Version == grp.Max(x => x.GetName().Version))) // only select distinct assemblies based on FullName to avoid loading duplicate assemblies .Select(a => CompilerReference.From(a)) .Concat(includeAssemblies ?? Enumerable.Empty<CompilerReference>()); }
public void GenerateTestMethods_SingleParametrizedConstructorTypeGiven_ShouldBuildSingleTestMethod() { var context = new TypeContext(typeof(TestAssembly.ClassContructor), false); var result = testee.GenerateTestMethods(context); result.Should().NotBeNull(); result.Should().ContainSingle(); result.First().Name.Should().Be(expectedMethodName); result.First().SourceCode.Should().Be(expectedSourceCode); }
public void GenerateTestMethods_InternalConstructorTypeWithInternalsVisibleGiven_ShouldNotReturnAnyTestMethod() { var context = new TypeContext(typeof(TestAssembly.InternalContructorParameter), true); var result = testee.GenerateTestMethods(context); result.Should().NotBeNull(); result.Should().ContainSingle(); result.First().Name.Should().Be(expectedMethodName); result.First().SourceCode.Should().Be(expectedSourceCode); }
public void GenerateTestMethods_DefaultConstructorTypeGiven() { var context = new TypeContext(typeof(TestAssembly.PublicClass), false); var result = testee.GenerateTestMethods(context); result.Should().NotBeNull(); result.Should().HaveCount(2); result.Should().OnlyContain(x => x.Name == expectedMethodName); result.Should().OnlyContain(x => x.SourceCode == expectedSourceCode); }
public void ShouldSupportDatetimeOffsetAsStrings() { var context = new TypeContext(new Settings { UseNativeDates = false }); var resolvedType = context.GetTypeScriptType(typeof(DateTimeOffset).FullName); Assert.IsInstanceOfType(resolvedType, typeof(StringType)); }
public void GenerateTestMethods_TypeContainingInternalMethodGiven() { var context = new TypeContext(typeof(TestAssembly.InternalClass), true); var result = testee.GenerateTestMethods(context); result.Should().NotBeNull(); result.Should().HaveCount(1); result.Should().OnlyContain(x => x.Name == expectedMethodName); result.Should().OnlyContain(x => x.SourceCode == expectedSourceCode); }
private string GetTypeContextShortName(TypeContext c) { switch (c) { case TypeContext.GenericArgument: return "ga"; case TypeContext.TypeOf: return "to"; case TypeContext.UseStaticMember: return "sm"; case TypeContext.CastTarget: return "ct"; case TypeContext.GetDefaultValue: return "def"; case TypeContext.BindBaseCall: return "bind"; default: throw new ArgumentException("c"); } }
private JsExpression GetTypeDefinitionScriptType(ITypeDefinition type, TypeContext context) { if (context != TypeContext.GetScriptType && context != TypeContext.TypeOf && !MetadataUtils.DoesTypeObeyTypeSystem(type)) { return CreateTypeReferenceExpression(KnownTypeReference.Object); } else if (MetadataUtils.IsSerializable(type) && !MetadataUtils.DoesTypeObeyTypeSystem(type)) { return CreateTypeReferenceExpression(KnownTypeReference.Object); } else { return CreateTypeReferenceExpression(type); } }
public bool ShouldWriteOldIndex(TypeContext tc) { if(WriteIndex == WriteIndex.Always) return true; if (WriteIndex == Web.WriteIndex.ForSavedEntities) { IdentifiableEntity ie = tc.Parent.Follow(a => a.Parent).OfType<TypeContext>().Select(a => a.UntypedValue).OfType<IdentifiableEntity>().FirstEx(() => "Parent entity not found"); return !ie.IsNew; } return false; }
public static MvcHtmlString QueryTokenDNBuilder(this HtmlHelper helper, TypeContext<QueryTokenEntity> ctx, QueryTokenBuilderSettings settings) { if (ctx.Value.Try(qt => qt.ParseException) != null) { HtmlStringBuilder sb = new HtmlStringBuilder(); sb.Add(new HtmlTag("div").Class("ui-state-error").SetInnerText(ctx.Value.ParseException.Message).ToHtml()); sb.Add(new HtmlTag("pre").SetInnerText(ctx.Value.TokenString).ToHtml()); sb.Add(helper.QueryTokenBuilder(null, ctx, settings)); return sb.ToHtml(); } else { return helper.QueryTokenBuilder(ctx.Value.Try(ct => ct.Token), ctx, settings); } }
public void one_record_extends_not_existed_type() { var context = new TypeContext(); var tag = Guid.NewGuid(); context.DefineRecord(builder => builder .SetName("First") .SetTag(tag) .SetBaseType("NotExistedType") ); Assert.Throws<TypeNotFoundException>(() => { context.Build(); }); }
private JsExpression GetTypeDefinitionScriptType(ITypeDefinition type, TypeContext context) { var sem = _metadataImporter.GetTypeSemantics(type); if (sem.Type == TypeScriptSemantics.ImplType.NotUsableFromScript) { _errorReporter.Message(Saltarelle.Compiler.Messages._7522, type.FullName); return JsExpression.Null; } if (context != TypeContext.GetScriptType && context != TypeContext.TypeOf && !MetadataUtils.DoesTypeObeyTypeSystem(type)) { return CreateTypeReferenceExpression(KnownTypeReference.Object); } else if (MetadataUtils.IsSerializable(type) && !MetadataUtils.DoesTypeObeyTypeSystem(type)) { return CreateTypeReferenceExpression(KnownTypeReference.Object); } else { return CreateTypeReferenceExpression(type); } }
public void record_type_without_fields_and_with_namespace() { var context = new TypeContext(); var tag = Guid.NewGuid(); context.DefineRecord(builder => builder .SetName("SomeNamespace.First") .SetTag(tag) ); context.Build(); var firstType = context.GetRecordType("SomeNamespace.First"); Assert.That(firstType.FullName, Is.EqualTo("SomeNamespace.First")); Assert.That(firstType.Name, Is.EqualTo("First")); Assert.That(firstType.Namespace, Is.EqualTo("SomeNamespace")); Assert.That(firstType.Tag, Is.EqualTo(tag)); Assert.That(firstType.BaseType, Is.Null); Assert.That(firstType.GetFields().Count, Is.EqualTo(0)); }
public void one_record_extends_not_record_type() { var context = new TypeContext(); var tag = Guid.NewGuid(); context.DefineRecord(builder => builder .SetName("First") .SetTag(tag) .SetBaseType("Abracadabra") ); context.DefineEnum(builder => builder .SetName("Abracadabra") .AddConstant(1, "First") .AddConstant(2, "Second") ); Assert.Throws<TypeMismatchException>(() => { context.Build(); }); }
public SyntaxTypeReference WithContext(TypeContext context = TypeContext.None) => new(Type, context, Scope);
public async Task <ActionResult> AddTask() { var useID = 0; var cmpID = 0; var cmpName = ""; Users item; if (Session["useDetails"] != null) { item = Session["useDetails"] as Users; useID = item.useID; cmpID = item.useCompanyID; cmpName = item.useCompanyName; } TasksModel model = new TasksModel(); List <CompanyModel> cmpModel = new List <CompanyModel>(); List <TypeModel> typModel = new List <TypeModel>(); List <PriorityModel> ptyModel = new List <PriorityModel>(); List <Users> usrModel = new List <Users>(); CompanyContext cmpContext = new CompanyContext(); TypeContext typContext = new TypeContext(); PriorityContext ptyContext = new PriorityContext(); UserContext useContext = new UserContext(); cmpModel = await cnnVM.CompanyConnectionDropDown(cmpID, cmpName); typModel = typContext.TypeDropDown(); ptyModel = ptyContext.PriorityDropDown(); usrModel = useContext.UsersDropDownController(cmpID); model.tasID = cmpID; foreach (var company in cmpModel) { model.Companies.Add(new SelectListItem { Text = company.cmpName, Value = company.cmpID.ToString() }); } foreach (var type in typModel) { model.Types.Add(new SelectListItem { Text = type.typName, Value = type.typID.ToString() }); } foreach (var priority in ptyModel) { model.Priorites.Add(new SelectListItem { Text = priority.ptyName, Value = priority.ptyID.ToString() }); } foreach (var user in usrModel) { model.Users.Add(new SelectListItem { Text = user.useName, Value = user.useID.ToString() }); } model.tasDelagatedBy = useID; return(View(model)); }
public virtual void CopyFrom(TypeContext context) { base.CopyFrom(context); }
private bool TryGetMember(TypeScriptInterface interfaceContext, CodeProperty property, TypeContext typeContext, out TypeScriptMember member) { member = null; if (property.Access != vsCMAccess.vsCMAccessPublic) { return(false); } var getter = property.Getter; if (getter == null) { return(false); } var values = GetMemberValues(property, typeContext); string name; if (values.Name != null) { name = values.Name; } else { name = property.Name; if (name.StartsWith("@")) { name = name.Substring(1); } } TypeReference memberType; if (!string.IsNullOrWhiteSpace(values.Type)) { memberType = typeContext.GetLiteralReference(values.Type); } else { memberType = typeContext.GetTypeReference( TypeName.ParseDte(getter.Type.AsFullName), interfaceContext); } member = new TypeScriptMember { Name = name, //FullName = property.FullName, Optional = values.Optional, Ignore = values.Ignore, Type = memberType }; if (member.Ignore) { return(false); } if (values.CamelCase && values.Name == null) { member.Name = member.Name.Substring(0, 1).ToLowerInvariant() + member.Name.Substring(1); } return(true); }
internal static NativeFormatMethodParameterInfo GetNativeFormatMethodParameterInfo(MethodBase member, MethodHandle methodHandle, int position, ParameterHandle parameterHandle, QSignatureTypeHandle qualifiedParameterType, TypeContext typeContext) { return(new NativeFormatMethodParameterInfo(member, methodHandle, position, parameterHandle, qualifiedParameterType, typeContext)); }
public override Tuple <Type, CompilationData> CompileType(TypeContext context) { var sourceCode = GetCodeCompileUnit(context); var assemblyName = GetAssemblyName(context); (new PermissionSet(PermissionState.Unrestricted)).Assert(); var tempDir = GetTemporaryDirectory(); var sourceCodeFile = Path.Combine(tempDir, String.Format("{0}.{1}", assemblyName, SourceFileExtension)); File.WriteAllText(sourceCodeFile, sourceCode); var references = GetAllReferences(context); var compilation = GetEmptyCompilation(assemblyName) .AddSyntaxTrees( GetSyntaxTree(sourceCode, sourceCodeFile)) .AddReferences(GetMetadataReferences(references)); compilation = compilation .WithOptions( CreateOptions(context) .WithOutputKind(OutputKind.DynamicallyLinkedLibrary) .WithPlatform(Platform.AnyCpu) .WithSourceReferenceResolver(new RazorEngineSourceReferenceResolver(sourceCodeFile))); var assemblyFile = Path.Combine(tempDir, String.Format("{0}.dll", assemblyName)); var assemblyPdbFile = Path.Combine(tempDir, String.Format("{0}.pdb", assemblyName)); var compilationData = new CompilationData(sourceCode, tempDir); using (var assemblyStream = File.Open(assemblyFile, FileMode.Create, FileAccess.ReadWrite)) using (var pdbStream = File.Open(assemblyPdbFile, FileMode.Create, FileAccess.ReadWrite)) { var opts = new EmitOptions() .WithPdbFilePath(assemblyPdbFile); var pdbStreamHelper = pdbStream; if (IsMono()) { opts = opts.WithDebugInformationFormat(DebugInformationFormat.PortablePdb); } var result = Debugger.IsAttached ? compilation.Emit(assemblyStream, pdbStreamHelper, options: opts) : compilation.Emit(assemblyStream); if (!result.Success) { var errors = result.Diagnostics.Select(diag => { var lineSpan = diag.Location.GetLineSpan(); return(new Templating.RazorEngineCompilerError( string.Format("{0}", diag.GetMessage()), lineSpan.Path, lineSpan.StartLinePosition.Line, lineSpan.StartLinePosition.Character, diag.Id, diag.Severity != DiagnosticSeverity.Error)); }); throw new Templating.TemplateCompilationException(errors, compilationData, context.TemplateContent); } } // load file and return loaded type. Assembly assembly; if (DisableTempFileLocking) { assembly = File.Exists(assemblyPdbFile) ? Assembly.Load(File.ReadAllBytes(assemblyFile), File.ReadAllBytes(assemblyPdbFile)) : Assembly.Load(File.ReadAllBytes(assemblyFile)); } else { assembly = Assembly.LoadFrom(assemblyFile); } var type = assembly.GetType(DynamicTemplateNamespace + "." + context.ClassName); return(Tuple.Create(type, compilationData)); }
/// <summary> /// Create a empty CompilationOptions with the given namespace usings. /// </summary> /// <param name="context"></param> /// <returns></returns> public abstract CompilationOptions CreateOptions(TypeContext context);
private OperationType GetOperation( TypeContext tc, ResolvedTypeCategory leftType, ResolvedTypeCategory rightType, string op) { Dictionary <string, Dictionary <ResolvedTypeCategory, Dictionary <ResolvedTypeCategory, OperationType> > > consolidationLookup; if (tc.OpConsolidationLookupHack != null) { consolidationLookup = (Dictionary <string, Dictionary <ResolvedTypeCategory, Dictionary <ResolvedTypeCategory, OperationType> > >)tc.OpConsolidationLookupHack; } else { consolidationLookup = new Dictionary <string, Dictionary <ResolvedTypeCategory, Dictionary <ResolvedTypeCategory, OperationType> > >(); tc.OpConsolidationLookupHack = consolidationLookup; OperationType[] operations = new OperationType[] { new OperationType(ResolvedTypeCategory.NULL, ResolvedTypeCategory.NULL, "==", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, true)); }), new OperationType(ResolvedTypeCategory.NULL, ResolvedTypeCategory.NULL, "!=", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, false)); }), new OperationType(ResolvedTypeCategory.BOOLEAN, ResolvedTypeCategory.BOOLEAN, "==", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetBool(opChain.Left) == GetBool(opChain.Right))); }), new OperationType(ResolvedTypeCategory.BOOLEAN, ResolvedTypeCategory.BOOLEAN, "!=", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetBool(opChain.Left) != GetBool(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.INTEGER, "&", tc.INTEGER, (opChain) => { return(MakeInt(opChain.FirstToken, GetInt(opChain.Left) & GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.INTEGER, "|", tc.INTEGER, (opChain) => { return(MakeInt(opChain.FirstToken, GetInt(opChain.Left) | GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.INTEGER, "^", tc.INTEGER, (opChain) => { return(MakeInt(opChain.FirstToken, GetInt(opChain.Left) ^ GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.INTEGER, "<<", tc.INTEGER, (opChain) => { int right = GetInt(opChain.Right); if (right < 0) { throw new ParserException(opChain.FirstToken, "Cannot bit shift by a negative number."); } return(MakeInt(opChain.FirstToken, GetInt(opChain.Left) << right)); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.INTEGER, ">>", tc.INTEGER, (opChain) => { int right = GetInt(opChain.Right); if (right < 0) { throw new ParserException(opChain.FirstToken, "Cannot bit shift by a negative number."); } return(MakeInt(opChain.FirstToken, GetInt(opChain.Left) >> right)); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.INTEGER, "+", tc.INTEGER, (opChain) => { return(MakeInt(opChain.FirstToken, GetInt(opChain.Left) + GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.INTEGER, "-", tc.INTEGER, (opChain) => { return(MakeInt(opChain.FirstToken, GetInt(opChain.Left) - GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.INTEGER, "*", tc.INTEGER, (opChain) => { return(MakeInt(opChain.FirstToken, GetInt(opChain.Left) * GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.INTEGER, "/", tc.INTEGER, (opChain) => { CheckZero(opChain.Right); return(MakeInt(opChain.FirstToken, GetInt(opChain.Left) / GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.INTEGER, "%", tc.INTEGER, (opChain) => { return(MakeInt(opChain.FirstToken, PositiveModInt(opChain.Left, opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.INTEGER, "<=", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetInt(opChain.Left) <= GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.INTEGER, ">=", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetInt(opChain.Left) >= GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.INTEGER, "<", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetInt(opChain.Left) < GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.INTEGER, ">", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetInt(opChain.Left) > GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.INTEGER, "==", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetInt(opChain.Left) == GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.INTEGER, "!=", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetInt(opChain.Left) != GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.INTEGER, "**", tc.FLOAT, (opChain) => { int right = GetInt(opChain.Right); int left = GetInt(opChain.Left); if (right == 0) { return(MakeFloat(opChain.FirstToken, 1.0)); } return(MakeFloat(opChain.FirstToken, Math.Pow(left, right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.FLOAT, "+", tc.FLOAT, (opChain) => { return(MakeFloat(opChain.FirstToken, GetInt(opChain.Left) + GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.FLOAT, "-", tc.FLOAT, (opChain) => { return(MakeFloat(opChain.FirstToken, GetInt(opChain.Left) - GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.FLOAT, "*", tc.FLOAT, (opChain) => { return(MakeFloat(opChain.FirstToken, GetInt(opChain.Left) * GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.FLOAT, "/", tc.FLOAT, (opChain) => { CheckZero(opChain.Right); return(MakeFloat(opChain.FirstToken, GetInt(opChain.Left) / GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.FLOAT, "%", tc.FLOAT, (opChain) => { return(MakeFloat(opChain.FirstToken, PositiveModFloat(opChain.Left, opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.FLOAT, "<=", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetInt(opChain.Left) <= GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.FLOAT, ">=", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetInt(opChain.Left) >= GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.FLOAT, "<", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetInt(opChain.Left) < GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.FLOAT, ">", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetInt(opChain.Left) > GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.FLOAT, "==", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetInt(opChain.Left) == GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.FLOAT, "!=", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetInt(opChain.Left) != GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.FLOAT, "**", tc.FLOAT, (opChain) => { double right = GetFloat(opChain.Right); int left = GetInt(opChain.Left); if (FloatIsAbsoluteZero(right)) { return(MakeFloat(opChain.FirstToken, 1.0)); } if (!FloatIsAbsoluteZero(right % 1) && left < 0) { throw new ParserException(opChain.OpToken, "Exponent creates a complex expression."); } return(MakeFloat(opChain.FirstToken, Math.Pow(left, right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.INTEGER, "+", tc.FLOAT, (opChain) => { return(MakeFloat(opChain.FirstToken, GetFloat(opChain.Left) + GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.INTEGER, "-", tc.FLOAT, (opChain) => { return(MakeFloat(opChain.FirstToken, GetFloat(opChain.Left) - GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.INTEGER, "*", tc.FLOAT, (opChain) => { return(MakeFloat(opChain.FirstToken, GetFloat(opChain.Left) * GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.INTEGER, "/", tc.FLOAT, (opChain) => { CheckZero(opChain.Right); return(MakeFloat(opChain.FirstToken, GetFloat(opChain.Left) / GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.INTEGER, "%", tc.FLOAT, (opChain) => { return(MakeFloat(opChain.FirstToken, PositiveModFloat(opChain.Left, opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.INTEGER, "<=", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetFloat(opChain.Left) <= GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.INTEGER, ">=", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetFloat(opChain.Left) >= GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.INTEGER, "<", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetFloat(opChain.Left) < GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.INTEGER, ">", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetFloat(opChain.Left) > GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.INTEGER, "==", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetFloat(opChain.Left) == GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.INTEGER, "!=", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetFloat(opChain.Left) != GetInt(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.INTEGER, "**", tc.FLOAT, (opChain) => { int right = GetInt(opChain.Right); double left = GetFloat(opChain.Left); if (right == 0) { return(MakeFloat(opChain.FirstToken, 1.0)); } return(MakeFloat(opChain.FirstToken, Math.Pow(left, right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.FLOAT, "+", tc.FLOAT, (opChain) => { return(MakeFloat(opChain.FirstToken, GetFloat(opChain.Left) + GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.FLOAT, "-", tc.FLOAT, (opChain) => { return(MakeFloat(opChain.FirstToken, GetFloat(opChain.Left) - GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.FLOAT, "*", tc.FLOAT, (opChain) => { return(MakeFloat(opChain.FirstToken, GetFloat(opChain.Left) * GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.FLOAT, "/", tc.FLOAT, (opChain) => { CheckZero(opChain.Right); return(MakeFloat(opChain.FirstToken, GetFloat(opChain.Left) / GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.FLOAT, "%", tc.FLOAT, (opChain) => { return(MakeFloat(opChain.FirstToken, PositiveModFloat(opChain.Left, opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.FLOAT, "<=", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetFloat(opChain.Left) <= GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.FLOAT, ">=", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetFloat(opChain.Left) >= GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.FLOAT, "<", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetFloat(opChain.Left) < GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.FLOAT, ">", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetFloat(opChain.Left) > GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.FLOAT, "==", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetFloat(opChain.Left) == GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.FLOAT, "!=", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetFloat(opChain.Left) != GetFloat(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.FLOAT, "**", tc.FLOAT, (opChain) => { double right = GetFloat(opChain.Right); double left = GetFloat(opChain.Left); if (FloatIsAbsoluteZero(right)) { return(MakeFloat(opChain.FirstToken, 1.0)); } if (!FloatIsAbsoluteZero(right % 1) && left < 0) { throw new ParserException(opChain.OpToken, "Exponent creates a complex expression."); } return(MakeFloat(opChain.FirstToken, Math.Pow(left, right))); }), new OperationType(ResolvedTypeCategory.BOOLEAN, ResolvedTypeCategory.STRING, "+", tc.STRING, (opChain) => { return(MakeString(opChain.FirstToken, GetBool(opChain.Left).ToString() + GetString(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.STRING, "+", tc.STRING, (opChain) => { return(MakeString(opChain.FirstToken, GetInt(opChain.Left).ToString() + GetString(opChain.Right))); }), new OperationType(ResolvedTypeCategory.FLOAT, ResolvedTypeCategory.STRING, "+", tc.STRING, (opChain) => { return(MakeString(opChain.FirstToken, GetFloatAsString(opChain.Left) + GetString(opChain.Right))); }), new OperationType(ResolvedTypeCategory.STRING, ResolvedTypeCategory.BOOLEAN, "+", tc.STRING, (opChain) => { return(MakeString(opChain.FirstToken, GetString(opChain.Left) + GetBool(opChain.Right).ToString())); }), new OperationType(ResolvedTypeCategory.STRING, ResolvedTypeCategory.INTEGER, "+", tc.STRING, (opChain) => { return(MakeString(opChain.FirstToken, GetString(opChain.Left) + GetInt(opChain.Right).ToString())); }), new OperationType(ResolvedTypeCategory.STRING, ResolvedTypeCategory.FLOAT, "+", tc.STRING, (opChain) => { return(MakeString(opChain.FirstToken, GetString(opChain.Left) + GetFloatAsString(opChain.Right))); }), new OperationType(ResolvedTypeCategory.STRING, ResolvedTypeCategory.STRING, "+", tc.STRING, (opChain) => { return(MakeString(opChain.FirstToken, GetString(opChain.Left) + GetString(opChain.Right))); }), new OperationType(ResolvedTypeCategory.STRING, ResolvedTypeCategory.STRING, "==", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetString(opChain.Left) == GetString(opChain.Right))); }), new OperationType(ResolvedTypeCategory.STRING, ResolvedTypeCategory.STRING, "!=", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetString(opChain.Left) != GetString(opChain.Right))); }), new OperationType(ResolvedTypeCategory.STRING, ResolvedTypeCategory.INSTANCE, "+", tc.STRING, null), new OperationType(ResolvedTypeCategory.INSTANCE, ResolvedTypeCategory.STRING, "+", tc.STRING, null), new OperationType(ResolvedTypeCategory.STRING, ResolvedTypeCategory.CLASS_DEFINITION, "+", tc.STRING, null), new OperationType(ResolvedTypeCategory.CLASS_DEFINITION, ResolvedTypeCategory.STRING, "+", tc.STRING, null), new OperationType(ResolvedTypeCategory.STRING, ResolvedTypeCategory.FUNCTION_POINTER, "+", tc.STRING, null), new OperationType(ResolvedTypeCategory.FUNCTION_POINTER, ResolvedTypeCategory.STRING, "+", tc.STRING, null), new OperationType(ResolvedTypeCategory.STRING, ResolvedTypeCategory.LIST, "+", tc.STRING, null), new OperationType(ResolvedTypeCategory.LIST, ResolvedTypeCategory.STRING, "+", tc.STRING, null), new OperationType(ResolvedTypeCategory.STRING, ResolvedTypeCategory.DICTIONARY, "+", tc.STRING, null), new OperationType(ResolvedTypeCategory.DICTIONARY, ResolvedTypeCategory.STRING, "+", tc.STRING, null), new OperationType(ResolvedTypeCategory.STRING, ResolvedTypeCategory.OBJECT, "+", tc.STRING, null), new OperationType(ResolvedTypeCategory.OBJECT, ResolvedTypeCategory.STRING, "+", tc.STRING, null), new OperationType(ResolvedTypeCategory.BOOLEAN, ResolvedTypeCategory.BOOLEAN, "&&", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetBool(opChain.Left) && GetBool(opChain.Right))); }), new OperationType(ResolvedTypeCategory.BOOLEAN, ResolvedTypeCategory.BOOLEAN, "||", tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, GetBool(opChain.Left) || GetBool(opChain.Right))); }), new OperationType(ResolvedTypeCategory.INTEGER, ResolvedTypeCategory.STRING, "*", tc.STRING, (opChain) => { return(GenerateMultipliedStringIfNotTooLong(opChain, opChain.Left, opChain.Right)); }), new OperationType(ResolvedTypeCategory.STRING, ResolvedTypeCategory.INTEGER, "*", tc.STRING, (opChain) => { return(GenerateMultipliedStringIfNotTooLong(opChain, opChain.Left, opChain.Right)); }), }; foreach (OperationType ot in operations) { if (!consolidationLookup.ContainsKey(ot.Op)) { consolidationLookup[ot.Op] = new Dictionary <ResolvedTypeCategory, Dictionary <ResolvedTypeCategory, OperationType> >(); } if (!consolidationLookup[ot.Op].ContainsKey(ot.LeftType)) { consolidationLookup[ot.Op][ot.LeftType] = new Dictionary <ResolvedTypeCategory, OperationType>(); } consolidationLookup[ot.Op][ot.LeftType].Add(ot.RightType, ot); // causes exception if duplicate } } // The op will always have some types registered, so you can dereference the first level of lookups without checking. Dictionary <ResolvedTypeCategory, Dictionary <ResolvedTypeCategory, OperationType> > l1 = consolidationLookup[op]; if (l1.ContainsKey(leftType)) { Dictionary <ResolvedTypeCategory, OperationType> l2 = l1[leftType]; if (l2.ContainsKey(rightType)) { return(l2[rightType]); } } if (op == "==") { // == comparisons between different kinds of objects should resolve to false at compile time. // Lazily initialize these operation types as they are encountered. if (leftType != rightType && !(leftType == ResolvedTypeCategory.INTEGER && rightType == ResolvedTypeCategory.FLOAT) && !(leftType == ResolvedTypeCategory.FLOAT && rightType == ResolvedTypeCategory.INTEGER) && leftType != ResolvedTypeCategory.ANY && rightType != ResolvedTypeCategory.ANY && leftType != ResolvedTypeCategory.OBJECT && rightType != ResolvedTypeCategory.OBJECT) { if (!consolidationLookup[op].ContainsKey(leftType)) { consolidationLookup[op][leftType] = new Dictionary <ResolvedTypeCategory, OperationType>(); } OperationType ot = new OperationType(leftType, rightType, op, tc.BOOLEAN, (opChain) => { return(MakeBool(opChain.FirstToken, false)); }); consolidationLookup[op][leftType][rightType] = ot; return(ot); } } return(null); }
/// <summary> /// Creates a CSharpCompilationOptions instance. /// </summary> /// <param name="context"></param> /// <returns></returns> public override CompilationOptions CreateOptions(TypeContext context) { return (new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary) .WithUsings(context.Namespaces)); }
private void WriteTypeMembers(TypeDefinition type, Action <IMemberDefinition> writeMember, IEnumerable <string> attributesToSkip = null, ICollection <string> fieldsToSkip = null) { List <IMemberDefinition> members = Utilities.GetTypeMembers(type, Language, this.Settings.ShowCompilerGeneratedMembers, attributesToSkip, fieldsToSkip, currentWritingInfo.GeneratedFilterMethods, TypeContext.GetFieldToPropertyMap(Language).Keys); if (type.IsEnum) { members.Sort((x, y) => SortEnumFields(x, y)); } for (int i = 0; i < members.Count; i++) { IMemberDefinition member = null; if (isStopped) { return; } member = members[i]; if (member is FieldDefinition && (member as FieldDefinition).IsSpecialName) { continue; } membersStack.Push(member); bool isLastMember = (i == members.Count - 1); writeMember(member); if (type.IsEnum) { if (!isLastMember && members[i + 1].Name != "value__" /*inserted by the compiler as last member on some enums. not written.*/) { WriteEnumValueSeparator(); WriteLine(); } } else { if (!isLastMember) { WriteLine(); WriteLine(); } } membersStack.Pop(); } }
/// <summary> /// Returns the associated OpenCL type name. /// </summary> /// <param name="type">The managed type to use.</param> /// <returns>The resolved OpenCL type name.</returns> public string this[Type type] => this[TypeContext.CreateType(type)];
private static System.Reflection.MethodInfo[] GetMethods(TypeContext typeContext) { return(typeContext.TargetType.GetMethods() .Where(x => x.GetParameters().Count() > 1) .ToArray()); }
public void FillInMetadataDescribedParameters(ref VirtualRuntimeParameterInfoArray result, QSignatureTypeHandle[] typeSignatures, MethodBase contextMethod, TypeContext typeContext) { foreach (ParameterHandle parameterHandle in _method.GetParameters()) { Parameter parameterRecord = _reader.GetParameter(parameterHandle); int index = parameterRecord.SequenceNumber; result[index] = EcmaFormatMethodParameterInfo.GetEcmaFormatMethodParameterInfo( contextMethod, _methodHandle, index - 1, parameterHandle, typeSignatures[index], typeContext); } }
public TypeReference(Type nativeType, TypeContext context) { ClrType = nativeType ?? throw new ArgumentNullException(nameof(nativeType)); Context = context; }
private RuntimeThinMethodParameterInfo(MethodBase member, int position, QSignatureTypeHandle qualifiedParameterTypeHandle, TypeContext typeContext) : base(member, position, qualifiedParameterTypeHandle, typeContext) { }
private TypeContext type(int _p) { ParserRuleContext _parentctx = Context; int _parentState = State; TypeContext _localctx = new TypeContext(Context, _parentState); TypeContext _prevctx = _localctx; int _startState = 8; EnterRecursionRule(_localctx, 8, RULE_type, _p); try { int _alt; EnterOuterAlt(_localctx, 1); { { _localctx = new BoolContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 56; Match(T__10); } Context.Stop = TokenStream.LT(-1); State = 63; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream, 4, Context); while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER) { if (_alt == 1) { if (ParseListeners != null) { TriggerExitRuleEvent(); } _prevctx = _localctx; { { _localctx = new ArrowContext(new TypeContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_type); State = 58; if (!(Precpred(Context, 2))) { throw new FailedPredicateException(this, "Precpred(Context, 2)"); } State = 59; Match(T__9); State = 60; type(3); } } } State = 65; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream, 4, Context); } } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { UnrollRecursionContexts(_parentctx); } return(_localctx); }
public override void Execute() { WriteLiteral("\r\n\r\n"); #line 11 "..\..\Dashboard\Views\UserChartPart.cshtml" Write(Html.ScriptCss("~/Chart/Content/Chart.css")); #line default #line hidden WriteLiteral("\r\n\r\n"); #line 13 "..\..\Dashboard\Views\UserChartPart.cshtml" using (var tc = Html.TypeContext <UserChartPartEntity>()) { UserChartEntity uc = tc.Value.UserChart; ChartRequest request = uc.ToRequest(); using (var crc = new TypeContext <ChartRequest>(request, tc.Prefix)) { #line default #line hidden WriteLiteral(" <div"); WriteAttribute("id", Tuple.Create(" id=\"", 541), Tuple.Create("\"", 576) #line 20 "..\..\Dashboard\Views\UserChartPart.cshtml" , Tuple.Create(Tuple.Create("", 546), Tuple.Create <System.Object, System.Int32>(crc.Compose("sfChartControl") #line default #line hidden , 546), false) ); WriteLiteral(" class=\"sf-chart-control SF-control-container\""); WriteLiteral(">\r\n <div"); WriteLiteral(" style=\"display: none\""); WriteLiteral(">\r\n"); WriteLiteral(" "); #line 22 "..\..\Dashboard\Views\UserChartPart.cshtml" Write(Html.HiddenRuntimeInfo(crc)); #line default #line hidden WriteLiteral("\r\n"); WriteLiteral(" "); #line 23 "..\..\Dashboard\Views\UserChartPart.cshtml" Write(Html.Hidden(crc.Compose("sfOrders"), request.Orders.IsNullOrEmpty() ? "" : (request.Orders.ToString(oo => (oo.OrderType == OrderType.Ascending ? "" : "-") + oo.Token.FullKey(), ";") + ";"))); #line default #line hidden WriteLiteral("\r\n"); #line 25 "..\..\Dashboard\Views\UserChartPart.cshtml" #line default #line hidden #line 25 "..\..\Dashboard\Views\UserChartPart.cshtml" ViewData[ViewDataKeys.QueryDescription] = DynamicQueryManager.Current.QueryDescription(request.QueryName); ViewData[ViewDataKeys.FilterOptions] = request.Filters.Select(f => new FilterOption { Token = f.Token, Operation = f.Operation, Value = f.Value }).ToList(); #line default #line hidden WriteLiteral("\r\n"); WriteLiteral(" "); #line 29 "..\..\Dashboard\Views\UserChartPart.cshtml" Write(Html.Partial(Finder.Manager.FilterBuilderView, crc)); #line default #line hidden WriteLiteral("\r\n <div"); WriteAttribute("id", Tuple.Create(" id=\"", 1325), Tuple.Create("\"", 1369) #line 30 "..\..\Dashboard\Views\UserChartPart.cshtml" , Tuple.Create(Tuple.Create("", 1330), Tuple.Create <System.Object, System.Int32>(crc.Compose("sfChartBuilderContainer") #line default #line hidden , 1330), false) ); WriteLiteral(" class=\"SF-control-container\""); WriteLiteral(">\r\n"); WriteLiteral(" "); #line 31 "..\..\Dashboard\Views\UserChartPart.cshtml" Write(Html.Partial(ChartClient.ChartBuilderView, crc)); #line default #line hidden WriteLiteral("\r\n </div>\r\n <script"); WriteLiteral(" type=\"text/javascript\""); WriteLiteral(">\r\n require([\""); #line 34 "..\..\Dashboard\Views\UserChartPart.cshtml" Write(ChartClient.Module); #line default #line hidden WriteLiteral("\"], function (Chart) {\r\n var options = "); #line 35 "..\..\Dashboard\Views\UserChartPart.cshtml" Write(MvcHtmlString.Create(uc.ToRequest().ToChartRequest(Url, tc.Prefix, tc.Value.ShowData ? ChartRequestMode.data: ChartRequestMode.chart).ToString())); #line default #line hidden WriteLiteral(";\r\n new Chart.ChartRequest(options);\r\n });\r\n " + " </script>\r\n </div> \r\n <div"); WriteAttribute("id", Tuple.Create(" id=\"", 1919), Tuple.Create("\"", 1952) #line 40 "..\..\Dashboard\Views\UserChartPart.cshtml" , Tuple.Create(Tuple.Create("", 1924), Tuple.Create <System.Object, System.Int32>(Model.Compose("divResults") #line default #line hidden , 1924), false) ); WriteLiteral(" class=\"sf-search-results-container\""); WriteLiteral(">\r\n"); WriteLiteral(" "); #line 41 "..\..\Dashboard\Views\UserChartPart.cshtml" Write(JavascriptMessage.searchForResults.NiceToString()); #line default #line hidden WriteLiteral("\r\n </div>\r\n </div>\r\n"); #line 44 "..\..\Dashboard\Views\UserChartPart.cshtml" } } #line default #line hidden }
public ArrowContext(TypeContext context) { CopyFrom(context); }
public virtual void WriteBody(TextWriter writer, Tab first, TypeContext context) { using (TabContainer.Surround(writer, new HtmlTag("div", context.Compose(this.Id)).Class("tab-pane fade").Class(this == first ? "in active" : null))) this.Body.WriteTo(writer); }
public BoolContext(TypeContext context) { CopyFrom(context); }
static void RunOptions(Options options) { if (!Directory.Exists(options.InputDir)) { return; } LogHandler logHandler = new LogHandler((type, id, msg) => { string msgType = "Info"; Color color = Color.White; if (type == LogType.Error) { msgType = "Error"; color = Color.Red; } else if (type == LogType.Warning) { msgType = "Warning"; color = Color.Yellow; } Colorful.Console.WriteLine($"[{msgType}] [{id}] {msg}", color); }); WorkbookReader reader = new WorkbookReader(logHandler); TypeContext context = new TypeContext(); context.Add(typeof(LogHandler), logHandler); Workbook[] workbooks = reader.ReadExcelFromDir(options.InputDir); if (workbooks != null && workbooks.Length > 0) { foreach (var workbook in workbooks) { string dir = $"{options.OutputDir}/{workbook.Name}"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } bool result = workbook.Verify(context); if (result) { for (int i = 0; i < workbook.SheetCount; ++i) { Sheet sheet = workbook.GetSheeetByIndex(i); if (options.Format == OutputFormat.Json) { JsonWriter.WriteTo(sheet, dir); } else if (options.Format == OutputFormat.Ndb) { NdbWriter.WriteTo(sheet, dir); } else if (options.Format == OutputFormat.Lua) { LuaWriter.WriteTo(sheet, dir); } } } } } context.Clear(); }
public async Task <ActionResult> AddTask(TasksModel tasks, HttpPostedFileBase[] postedFile) { var useID = 0; var cmpID = 0; var cmpName = ""; var item = Session["useDetails"] as Users; useID = item.useID; cmpID = item.useCompanyID; cmpName = item.useCompanyName; TasksModel model = new TasksModel(); List <CompanyModel> cmpModel = new List <CompanyModel>(); List <TypeModel> typModel = new List <TypeModel>(); List <PriorityModel> ptyModel = new List <PriorityModel>(); List <Users> usrModel = new List <Users>(); TypeContext typContext = new TypeContext(); CompanyContext cmpContext = new CompanyContext(); PriorityContext ptyContext = new PriorityContext(); UserContext useContext = new UserContext(); cmpModel = await cnnVM.CompanyConnectionDropDown(cmpID, cmpName); typModel = typContext.TypeDropDown(); ptyModel = ptyContext.PriorityDropDown(); usrModel = useContext.UsersDropDownController(cmpID); foreach (var country in cmpModel) { model.Companies.Add(new SelectListItem { Text = country.cmpName, Value = country.cmpID.ToString() }); } foreach (var type in typModel) { model.Types.Add(new SelectListItem { Text = type.typName, Value = type.typID.ToString() }); } foreach (var priority in ptyModel) { model.Priorites.Add(new SelectListItem { Text = priority.ptyName, Value = priority.ptyID.ToString() }); } foreach (var user in usrModel) { model.Users.Add(new SelectListItem { Text = user.useName, Value = user.useID.ToString() }); } model.tasDelagatedBy = tasks.tasDelagatedBy; model.tasDelegatedTo = tasks.tasDelegatedTo; //if (tasks.tasType > 0 && !string.IsNullOrWhiteSpace(tasks.tasTitle)) //{ // if (ModelState.IsValid == false) // { // return View(model); // } // else // { // var response = await taskVm.AddTask(tasks, postedFile); // if (response == true) // { // return RedirectToAction("Tasks"); // } // else // { // return View(model); // } // } //} //else //{ // ViewBag.CompanyID = tasks.tasDelegatedTo_Company; // return View(model); //} ViewBag.CompanyID = tasks.tasDelegatedTo_Company; return(View(model)); }
public ClrTypeReference( Type type, TypeContext context) : this(type, context, null, null) { }
public TypeMetadataBuilder(TypeContext context, TypeCache typeCache) { _context = context; _typeCache = typeCache; }
private JsExpression GetScriptType(IType type, TypeContext context, Func<ITypeParameter, JsExpression> resolveTypeParameter) { string contextName = GetTypeContextShortName(context); if (type is ParameterizedType) { var pt = (ParameterizedType)type; return JsExpression.Invocation(JsExpression.Identifier(contextName + "_$InstantiateGenericType"), new[] { new JsTypeReferenceExpression(Common.CreateMockTypeDefinition(type.Name, Common.CreateMockAssembly())) }.Concat(pt.TypeArguments.Select(a => GetScriptType(a, TypeContext.GenericArgument, resolveTypeParameter)))); } else if (type.TypeParameterCount > 0) { // This handles open generic types ( typeof(C<,>) ) return new JsTypeReferenceExpression(Common.CreateMockTypeDefinition(contextName + "_" + type.GetDefinition().Name, Common.CreateMockAssembly())); } else if (type.Kind == TypeKind.Array) { return JsExpression.Invocation(JsExpression.Identifier(contextName + "_$Array"), GetScriptType(((ArrayType)type).ElementType, TypeContext.GenericArgument, resolveTypeParameter)); } else if (type.Kind == TypeKind.Anonymous) { return JsExpression.Identifier(contextName + "_$Anonymous"); } else if (type is ITypeDefinition) { return new JsTypeReferenceExpression(Common.CreateMockTypeDefinition(contextName + "_" + type.Name, Common.CreateMockAssembly())); } else if (type is ITypeParameter) { return resolveTypeParameter((ITypeParameter)type); } else { throw new ArgumentException("Unsupported type + " + type); } }
static t Create <tArg>(tArg arg) { return(TypeContext <tArg> .Create(arg)); }
public virtual void WriteHeader(TextWriter writer, Tab first, TypeContext context) { using (TabContainer.Surround(writer, new HtmlTag("li").Class(this == first ? "active" : null))) using (TabContainer.Surround(writer, new HtmlTag("a").Attr("href", "#" + context.Compose(this.Id)).Attr("data-toggle", "tab").Attr("title", this.ToolTip))) this.Title.WriteTo(writer); }
static t Create() { return(TypeContext.creator()); }
public TabContainer(HtmlHelper helper, TypeContext context, string containerId) { this.helper = helper; this.context = context; this.containerId = containerId; }
JsExpression IRuntimeLibrary.GetScriptType(IType type, TypeContext context) { return(GetScriptType(type, context)); }
public TypeScriptInterface Build( CodeClass codeClass, TypeContext typeContext) { TypeScriptInterface result = null; TypeScriptInterfaceAttributeValues attributeValues = this.GetAttributeValues(codeClass); if (attributeValues != null) { string moduleName = attributeValues.Module; if (String.IsNullOrEmpty(moduleName) && codeClass.Namespace != null) { moduleName = codeClass.Namespace.FullName; } bool interfaceCreated; result = typeContext.GetOrCreateInterface( moduleName, TypeName.ParseDte(codeClass.FullName), GetInterfaceName(attributeValues), out interfaceCreated); if (!String.IsNullOrEmpty(attributeValues.Extends)) { result.Parent = typeContext.GetLiteralReference(attributeValues.Extends); } else if (codeClass.Bases.Count > 0) { // Getting the first item directly causes problems in unit tests. Get it from an enumerator. IEnumerator enumerator = codeClass.Bases.GetEnumerator(); enumerator.MoveNext(); TypeName parentTypeName = TypeName.ParseDte( ((CodeElement)enumerator.Current).FullName); if (BuilderHelper.IsValidBaseType(parentTypeName)) { result.Parent = typeContext.GetTypeReference( parentTypeName, result); } } result.IndexedType = this.GetIndexedType( result, codeClass, typeContext); Traversal.TraverseProperties( codeClass.Members, (property) => { TypeScriptMember member; if (TryGetMember( result, property, typeContext, out member)) { result.Fields.Add(member); } }); } return(result); }
internal static RuntimeThinMethodParameterInfo GetRuntimeThinMethodParameterInfo(MethodBase member, int position, QSignatureTypeHandle qualifiedParameterType, TypeContext typeContext) { return(new RuntimeThinMethodParameterInfo(member, position, qualifiedParameterType, typeContext)); }
[Pure][SecuritySafeCritical] // This should not be SecuritySafeCritical (make the template classes SecurityCritical instead) public virtual Tuple<Type, CompilationData> CreateTemplateType(ITemplateSource razorTemplate, Type modelType) { var context = new TypeContext { ModelType = modelType ?? typeof(System.Dynamic.DynamicObject), TemplateContent = razorTemplate, TemplateType = (_config.BaseTemplateType) ?? typeof(TemplateBase<>) }; foreach (string ns in _config.Namespaces) context.Namespaces.Add(ns); var service = _config .CompilerServiceFactory .CreateCompilerService(_config.Language); service.Debug = _config.Debug; service.DisableTempFileLocking = _config.DisableTempFileLocking; #if !RAZOR4 #pragma warning disable 0618 // Backwards Compat. service.CodeInspectors = _config.CodeInspectors ?? Enumerable.Empty<ICodeInspector>(); #pragma warning restore 0618 // Backwards Compat. #endif service.ReferenceResolver = _config.ReferenceResolver ?? new UseCurrentAssembliesReferenceResolver(); var result = service.CompileType(context); return result; }
private TypeScriptMemberAttributeValues GetMemberValues(CodeProperty property, TypeContext typeContext) { bool? attributeOptional = null; bool? attributeCamelCase = null; bool attributeIgnore = false; string attributeName = null; string attributeType = null; CodeAttribute attribute; if (TryGetAttribute(property.Attributes, MemberAttributeFullName, out attribute)) { var values = GetAttributeValues(attribute); bool parsedProperty; if (values.ContainsKey("Optional") && bool.TryParse(values["Optional"], out parsedProperty)) { attributeOptional = parsedProperty; } if (values.ContainsKey("CamelCase") && bool.TryParse(values["CamelCase"], out parsedProperty)) { attributeCamelCase = parsedProperty; } if (values.ContainsKey("Ignore") && bool.TryParse(values["Ignore"], out parsedProperty)) { attributeIgnore = parsedProperty; } values.TryGetValue("Name", out attributeName); values.TryGetValue("Type", out attributeType); } return(new TypeScriptMemberAttributeValues { Optional = attributeOptional.HasValue ? attributeOptional.Value : this.settings.DefaultOptional, Name = attributeName, Type = attributeType, CamelCase = attributeCamelCase ?? this.settings.DefaultCamelCaseMemberNames, Ignore = attributeIgnore }); }