public IEnumerable<IWebElement> FindByPartialId(string id, Scope scope)
 {
     id = "_" + id;
     var xpath = String.Format(".//*[substring(@id, string-length(@id) - {0} + 1, string-length(@id)) = {1}]",
                               id.Length, xPath.Literal(id));
     return Find(By.XPath(xpath),scope);
 }
Beispiel #2
0
 private ExpansionContext(Stack<MethodBase> stack, Scope scope, NameGenerator names, IEnumerable<KeyValuePair<Sym, Expression>> env)
 {
     Stack = stack;
     Scope = scope;
     Names = names;
     Env = env.ToDictionary();
 }
Beispiel #3
0
        private object InvokeTarget(Scope scope) {
            if (scope == _optimizedContext.GlobalScope && !_optimizedContext.LanguageContext.EnableTracing) {
                EnsureCompiled();

                Exception e = PythonOps.SaveCurrentException();
                var funcCode = EnsureFunctionCode(_optimizedTarget, false, true);
                PushFrame(_optimizedContext, funcCode);
                try {
                    if (Ast.CompilerContext.SourceUnit.Kind == SourceCodeKind.Expression) {
                        return OptimizedEvalWrapper(funcCode);
                    }
                    return _optimizedTarget(funcCode);
                } finally {
                    PythonOps.RestoreCurrentException(e);
                    PopFrame();
                }
            }

            // if we're running against a different scope or we need tracing then re-compile the code.
            if (_unoptimizedCode == null) {
                // TODO: Copy instead of mutate
                ((PythonCompilerOptions)Ast.CompilerContext.Options).Optimized = false;
                Interlocked.CompareExchange(
                    ref _unoptimizedCode,
                    Ast.MakeLookupCode().ToScriptCode(),
                    null
                );
            }

            // This is a brand new ScriptCode which also handles all appropriate ScriptCode
            // things such as pushing a function code or updating the stack trace for
            // exec/eval code.  Therefore we don't need to do any of that here.
            return _unoptimizedCode.Run(scope);
        }
Beispiel #4
0
 // copy constructor
 // ================
 // 
 private Scope(Scope other)
     : this(new List<Utils.StoreEntry>(other.locals),
            other.esp_pos,
            new List<Utils.StoreEntry>(other.globals),
            other.func,
            new List<Utils.StoreEntry>(other.typedefs),
            new List<Utils.StoreEntry>(other.enums)) {}
Beispiel #5
0
        public GeneratedCodeVisitor(SourceWriter source, Dictionary<string, object> globalSymbols, NullBehaviour nullBehaviour)
        {
            _nullBehaviour = nullBehaviour;
            _source = source;

            _scope = new Scope(new Scope(null) { Variables = globalSymbols });
        }
Beispiel #6
0
        public void Execute(Machine machine, Stack<object> stack, Scope scope, Instruction instr)
        {
            int length = (int)machine.TakeByte();
            string name = machine.TakeBytes(length * sizeof(char)).AsString();

            scope.GetFunction(name).Call(machine);
        }
        protected override Scope GetScope(IClaimsPrincipal principal, RequestSecurityToken request)
        {
            Scope scope = new Scope(request.AppliesTo.Uri.AbsoluteUri, SecurityTokenServiceConfiguration.SigningCredentials);

            string encryptingCertificateName = WebConfigurationManager.AppSettings[ApplicationSettingsNames.EncryptingCertificateName];
            if (!string.IsNullOrEmpty(encryptingCertificateName))
            {
                scope.EncryptingCredentials = new X509EncryptingCredentials(CertificateUtilities.GetCertificate(StoreName.My, StoreLocation.LocalMachine, encryptingCertificateName));
            }
            else
            {
                scope.TokenEncryptionRequired = false;
            }

            if (!string.IsNullOrEmpty(request.ReplyTo))
            {
                scope.ReplyToAddress = request.ReplyTo;
            }
            else
            {
                scope.ReplyToAddress = scope.AppliesToAddress;
            }

            return scope;
        }
        public void Test()
        {
            var scope = new Scope();
            scope.Element<Custom>(new CustomSurrogate());

            scope.Element<Item>()
                .Elements()
                .Add(x => x.Name)
                .Add(x => x.Custom)
                .Add(x => x.Value)
                .End();

            var obj = new Item
            {
                Name = "item",
                Value = "test",
                Custom = new Custom
                {
                    InnerXml = "<test></test>"
                }
            };

            var xml = scope.ToXmlString(obj);

            var obj2 = new Item();
            scope.ReadXmlString(xml, obj2);

            Assert.AreEqual(obj.Name, obj2.Name);
            Assert.AreEqual(obj.Value, obj2.Value);
            Assert.AreEqual(obj.Custom.InnerXml, obj2.Custom.InnerXml);
        }
 public string GetProperty(string strPropertyName, string strFormat, System.Globalization.CultureInfo formatProvider, Entities.Users.UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
 {
     CultureInfo ci = formatProvider;
     if (strPropertyName.ToLower() == CultureDropDownTypes.EnglishName.ToString().ToLowerInvariant())
     {
         return PropertyAccess.PropertyAccess.FormatString(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(ci.EnglishName), strFormat);
     }
     else if (strPropertyName.ToLower() == CultureDropDownTypes.Lcid.ToString().ToLowerInvariant())
     {
         return ci.LCID.ToString();
     }
     else if (strPropertyName.ToLower() == CultureDropDownTypes.Name.ToString().ToLowerInvariant())
     {
         return PropertyAccess.PropertyAccess.FormatString(ci.Name, strFormat);
     }
     else if (strPropertyName.ToLower() == CultureDropDownTypes.NativeName.ToString().ToLowerInvariant())
     {
         return PropertyAccess.PropertyAccess.FormatString(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(ci.NativeName), strFormat);
     }
     else if (strPropertyName.ToLower() == CultureDropDownTypes.TwoLetterIsoCode.ToString().ToLowerInvariant())
     {
         return PropertyAccess.PropertyAccess.FormatString(ci.TwoLetterISOLanguageName, strFormat);
     }
     else if (strPropertyName.ToLower() == CultureDropDownTypes.ThreeLetterIsoCode.ToString().ToLowerInvariant())
     {
         return PropertyAccess.PropertyAccess.FormatString(ci.ThreeLetterISOLanguageName, strFormat);
     }
     else if (strPropertyName.ToLower() == CultureDropDownTypes.DisplayName.ToString().ToLowerInvariant())
     {
         return PropertyAccess.PropertyAccess.FormatString(ci.DisplayName, strFormat);
     }
     PropertyNotFound = true;
     return string.Empty;
 }
Beispiel #10
0
 public DeclareVariableNode(String type, String name, SGLNode expression, Scope scope)
 {
     this.type = type;
     this.name = name;
     this.expression = expression;
     this.scope = scope;
 }
 public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo AccessingUser, Scope CurrentScope, ref bool PropertyNotFound)
 {
     switch (propertyName.ToLowerInvariant())
     {
         case "url":
             return NewUrl(objParent.Language);
         case "flagsrc":
             return "/" + objParent.Language + ".gif";
         case "selected":
             return (objParent.Language == CultureInfo.CurrentCulture.Name).ToString();
         case "label":
             return Localization.GetString("Label", objParent.resourceFile);
         case "i":
             return Globals.ResolveUrl("~/images/Flags");
         case "p":
             return Globals.ResolveUrl(PathUtils.Instance.RemoveTrailingSlash(objPortal.HomeDirectory));
         case "s":
             return Globals.ResolveUrl(PathUtils.Instance.RemoveTrailingSlash(objPortal.ActiveTab.SkinPath));
         case "g":
             return Globals.ResolveUrl("~/portals/" + Globals.glbHostSkinFolder);
         default:
             PropertyNotFound = true;
             return string.Empty;
     }
 }
 public string GetProperty(string strPropertyName, string strFormat, System.Globalization.CultureInfo formatProvider, Entities.Users.UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
 {
     if (dr == null)
         return string.Empty;
     object valueObject = dr[strPropertyName];
     string OutputFormat = strFormat;
     if (string.IsNullOrEmpty(strFormat))
         OutputFormat = "g";
     if (valueObject != null)
     {
         switch (valueObject.GetType().Name)
         {
             case "String":
                 return PropertyAccess.PropertyAccess.FormatString(Convert.ToString(valueObject), strFormat);
             case "Boolean":
                 return (PropertyAccess.PropertyAccess.Boolean2LocalizedYesNo(Convert.ToBoolean(valueObject), formatProvider));
             case "DateTime":
             case "Double":
             case "Single":
             case "Int32":
             case "Int64":
                 return (((IFormattable)valueObject).ToString(OutputFormat, formatProvider));
             default:
                 return PropertyAccess.PropertyAccess.FormatString(valueObject.ToString(), strFormat);
         }
     }
     else
     {
         PropertyNotFound = true;
         return string.Empty;
     }
 }
 public override void ExitInnerBlock( Command command, Thread thread, Scope scope )
 {
     if ( new TLBit( command.ParamExpression.Evaluate( scope ) ).Value )
         thread.EnterBlock( command.InnerBlock );
     else
         thread.Advance();
 }
 public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
 {
     TimeZoneInfo userTimeZone = AccessingUser.Profile.PreferredTimeZone;
     switch (propertyName.ToLower())
     {
         case "current":
             if (format == string.Empty)
             {
                 format = "D";
             }
             return TimeZoneInfo.ConvertTime(DateTime.Now, userTimeZone).ToString(format, formatProvider);
         case "now":
             if (format == string.Empty)
             {
                 format = "g";
             }
             return TimeZoneInfo.ConvertTime(DateTime.Now, userTimeZone).ToString(format, formatProvider);
         case "system":
             if (format == String.Empty)
             {
                 format = "g";
             }
             return DateTime.Now.ToString(format, formatProvider);
         case "utc":
             if (format == String.Empty)
             {
                 format = "g";
             }
             return DateTime.Now.ToUniversalTime().ToString(format, formatProvider);
         default:
             PropertyNotFound = true;
             return string.Empty;
     }
 }
 private IWebElement FindButtonByText(string locator, Scope scope)
 {
     return
         elementFinder.Find(By.TagName("button"), scope).FirstOrDefault(e => textMatcher.TextMatches(e, locator)) ??
         elementFinder.Find(By.ClassName("button"), scope).FirstOrDefault(e => textMatcher.TextMatches(e, locator)) ??
         elementFinder.Find(By.XPath(".//*[@role = 'button']"), scope).FirstOrDefault(e => textMatcher.TextMatches(e, locator));
 }
Beispiel #16
0
        private static SyntaxNode Repository(SyntaxNode node, Scope scope)
        {
            //Hubo problemas con el templatecito bonito,
            //Roslyn espera que tu reemplaces una clase con otra
            //Por tanto hay que escupir la clase nada mas y annadir
            //la interfaz al scope

            var repository = node as ClassDeclarationSyntax;

            if (repository == null)
                throw new InvalidOperationException();

            //Vamos a suponer que quieres cambiar los metodos para que sean UnitOfWork
            //solo un ejemplo.
            var typeName = repository.Identifier.ToString();
            var className = typeName + "Repository";
            var interfaceName = "I" + typeName + "Repository";

            var methods = repository
                .DescendantNodes()
                .OfType<MethodDeclarationSyntax>();

            var @interface = repoInterface.Get<InterfaceDeclarationSyntax>(interfaceName)
                .AddMembers(methods
                    .Select(method => CSharp.MethodDeclaration(method.ReturnType, method.Identifier)
                        .WithParameterList(method.ParameterList)
                        .WithSemicolonToken(Roslyn.semicolon))
                    .ToArray());

            scope.AddType(@interface);

            return repoClass.Get<ClassDeclarationSyntax>(className, typeName, interfaceName)
                .AddMembers(methods.ToArray());
        }
Beispiel #17
0
 public Scope(BodyType bodyType, Scope parent, ReadOnlyArray<string> parameters)
 {
     _bodyType = bodyType;
     Parent = parent;
     _parameters = parameters;
     _rootScope = parent != null ? parent._rootScope : this;
 }
Beispiel #18
0
        public static void __init__(Scope/*!*/ scope, string name, string documentation) {
            scope.SetName(Symbols.Name, name);

            if (documentation != null) {
                scope.SetName(Symbols.Doc, documentation);
            }
        }
Beispiel #19
0
        /// <summary>Assigns all needed attributes to the tag</summary>
        /// <returns>This instance downcasted to base class</returns>
        public virtual IndexedTag attr(
            string abbr = null,
            string axis = null,
            string headers = null,
            Scope? scope = null,
            int? rowspan = null,
            int? colspan = null,
            string id = null,
            string @class = null,
            string style = null,
            string title = null,
            LangCode lang = null,
            string xmllang = null,
            Dir? dir = null,
            string onclick = null,
            string ondblclick = null,
            string onmousedown = null,
            string onmouseup = null,
            string onmouseover = null,
            string onmousemove = null,
            string onmouseout = null,
            string onkeypress = null,
            string onkeydown = null,
            string onkeyup = null,
            Align? align = null,
            char? @char = null,
            Length charoff = null,
            Valign? valign = null
        )
        {
            Abbr = abbr;
            Axis = axis;
            Headers = headers;
            Scope = scope;
            RowSpan = rowspan;
            ColSpan = colspan;
            Id = id;
            Class = @class;
            Style = style;
            Title = title;
            Lang = lang;
            XmlLang = xmllang;
            Dir = dir;
            OnClick = onclick;
            OnDblClick = ondblclick;
            OnMouseDown = onmousedown;
            OnMouseUp = onmouseup;
            OnMouseOver = onmouseover;
            OnMouseMove = onmousemove;
            OnMouseOut = onmouseout;
            OnKeyPress = onkeypress;
            OnKeyDown = onkeydown;
            OnKeyUp = onkeyup;
            Align = align;
            Char = @char;
            CharOff = charoff;
            Valign = valign;

            return this;
        }
Beispiel #20
0
 private IncludeToken(Token parent, Scope scope, Span span, PreprocessorToken prepToken, string fileName, bool searchFileDir)
     : base(parent, scope, span)
 {
     _prepToken = prepToken;
     _fileName = fileName;
     _searchFileDir = searchFileDir;
 }
        public GeneratedCodeVisitor(SourceBuilder output, Dictionary<string, object> globalSymbols, NullBehaviour nullBehaviour)
        {
            _nullBehaviour = nullBehaviour;
            _source = output;

            _scope = new Scope(new Scope(null) { Variables = globalSymbols });
        }
Beispiel #22
0
        private static SyntaxNode ProcessContract(SyntaxNode node, Scope scope, SyntacticalExtension<SyntaxNode> extension)
        {
            if (extension.Kind == ExtensionKind.Code)
            {
                var block = extension.Body as BlockSyntax;
                Debug.Assert(block != null);

                List<StatementSyntax> checks = new List<StatementSyntax>();
                foreach (var st in block.Statements)
                {
                    var stExpression = st as ExpressionStatementSyntax;
                    if (stExpression == null)
                    {
                        scope.AddError("contract01", "contracts only support boolean expressions", st);
                        continue;
                    }

                    var contractCheck = ContractCheck
                        .ReplaceNodes(ContractCheck
                            .DescendantNodes()
                            .OfType<ExpressionSyntax>()
                            .Where(expr => expr.ToString() == "__condition"),

                         (oldNode, newNode) =>
                            stExpression.Expression);

                    checks.Add(contractCheck);
                }

                return CSharp.Block(checks);
            }

            scope.AddError("contract02", "contract cannot return a value", node);
            return node;
        }
Beispiel #23
0
        public NativeCallContext(NativeMethod source, IElfObject @this, params IElfObject[] args) 
        {
            Stack = new Stack<IElfObject>();

            var callScope = new Scope();
            callScope.Add("@this", @this);
            source.FuncDef.Args.Zip(args, callScope.Add);
            Scopes = new Stack<Scope>();
            Scopes.Push(callScope);

            Source = source;
            if (source.FuncDef.Args.Count() != args.Length)
            {
                throw new UnexpectedElfRuntimeException(@this.VM, String.Format(
                   "Fatal error invoking native call '{0}({1})' with args '{2}'. Reason: args count mismatch.",
                   Source.Name, Source.FuncDef.Args.StringJoin(), args.StringJoin()));
            }

            CurrentEvi = 0;
            PrevEvi = -1;
            if (source.Body.IsNullOrEmpty())
            {
                throw new UnexpectedElfRuntimeException(@this.VM, String.Format(
                   "Fatal error invoking native call '{0}'. Reason: empty method body.", Source.Name));
            } 
        }
        /// <summary>
        /// Creates a <see cref="SetRequestMessage"/> with all contents.
        /// </summary>
        /// <param name="requestId">The request id.</param>
        /// <param name="version">Protocol version</param>
        /// <param name="community">Community name</param>
        /// <param name="variables">Variables</param>
        public SetRequestMessage(int requestId, VersionCode version, OctetString community, IList<Variable> variables)
        {
            if (variables == null)
            {
                throw new ArgumentNullException("variables");
            }
            
            if (community == null)
            {
                throw new ArgumentNullException("community");
            }
            
            if (version == VersionCode.V3)
            {
                throw new ArgumentException("only v1 and v2c are supported", "version");
            }
            
            Version = version;
            Header = Header.Empty;
            Parameters = SecurityParameters.Create(community);
            var pdu = new SetRequestPdu(
                requestId,
                variables);
            Scope = new Scope(pdu);
            Privacy = DefaultPrivacyProvider.DefaultPair;
 
            _bytes = this.PackMessage(null).ToBytes();
        }
Beispiel #25
0
        public void Execute(Machine machine, Stack<object> stack, Scope scope, Instruction instr)
        {
            int length;
            string name;

            switch (instr)
            {
                default:
                    throw new VMException("Something just went horribly wrong. Variable instructlet is not supposed to receive {0}", instr.ToString());

                case Instruction.SetVar:
                    length = (int)machine.TakeByte();
                    name = machine.TakeBytes(length).AsString();

                    machine.ExecuteNextInstructlet();
                    scope.SetVariable(name, stack.Pop());
                    break;

                case Instruction.GetVar:
                    length = (int)machine.TakeByte();
                    name = machine.TakeBytes((int)length).AsString();

                    stack.Push(scope.GetVariable(name));
                    break;
            }
        }
        public override void Execute( Command command, Thread thread, Scope scope )
        {
            TLSub sub = scope[ command.Identifier ] as TLSub;

            command.InnerBlock = sub.Block;
            thread.EnterBlock( command.InnerBlock, true, new Scope( sub.Scope ) );
        }
		public async void ProvisionAccessTokenAsync_AssertionTokenIsSigned() {
			var claims = new List<Claim>{
				new Claim( Constants.Claims.ISSUER, TestData.ISSUER ),
				new Claim( Constants.Claims.TENANT_ID, TestData.TENANT_ID.ToString() ),
				new Claim( Constants.Claims.USER_ID, TestData.USER )
			};

			var scopes = new Scope[] { };

			await m_accessTokenProvider
				.ProvisionAccessTokenAsync( claims, scopes )
				.SafeAsync();

			var publicKeys = ( await m_publicKeyDataProvider.GetAllAsync().SafeAsync() ).ToList();

			string expectedKeyId = publicKeys.First().Id.ToString();
			string actualKeyId = m_actualAssertion.Header.SigningKeyIdentifier[ 0 ].Id;

			Assert.AreEqual( 1, publicKeys.Count );
			Assert.AreEqual( expectedKeyId, actualKeyId );

			AssertClaimEquals( m_actualAssertion, Constants.Claims.ISSUER, TestData.ISSUER );
			AssertClaimEquals( m_actualAssertion, Constants.Claims.TENANT_ID, TestData.TENANT_ID.ToString() );
			AssertClaimEquals( m_actualAssertion, Constants.Claims.USER_ID, TestData.USER );
		}
Beispiel #28
0
        private object Run(Scope/*!*/ scope, bool bindGlobals) {
            RubyScope localScope;
            RubyContext context = (RubyContext)LanguageContext;

            switch (_kind) {
                case TopScopeFactoryKind.Hosted:
                    localScope = RubyTopLevelScope.CreateHostedTopLevelScope(scope, context, bindGlobals);
                    break;

                case TopScopeFactoryKind.Main:
                    localScope = RubyTopLevelScope.CreateTopLevelScope(scope, context, true);
                    break;

                case TopScopeFactoryKind.File:
                    localScope = RubyTopLevelScope.CreateTopLevelScope(scope, context, false);
                    break;

                case TopScopeFactoryKind.WrappedFile:
                    localScope = RubyTopLevelScope.CreateWrappedTopLevelScope(scope, context);
                    break;

                default:
                    throw Assert.Unreachable;                
            }

            return Target(localScope, localScope.SelfObject);
        }
Beispiel #29
0
 /// <summary>
 /// Authentication request class to setup a request for the AuthenticationUtility.Authenticate method.
 /// </summary>
 /// <param name="scope">The required scope to receive information for.
 /// Regarding to the Google's documentation, the scope has to begin with openid and then include profile or email or both.
 /// For details see https://developers.google.com/accounts/docs/OpenIDConnect#scope-param
 /// </param>
 public AuthenticationRequest(Scope scope)
 {
     Scope = scope;
 }
 public GreaterThan(Scope scope) : base(scope, ">", "cmpq\t%rax,%rcx\nmovq\t$0,%rax\nsetg\t%al")
 {
 }
Beispiel #31
0
 public RegisterFactoryAttribute(Type factoryType, Scope factoryScope = Scope.InstancePerResolution, Scope factoryTargetScope = Scope.InstancePerResolution)
 {
     FactoryType        = factoryType;
     FactoryScope       = factoryScope;
     FactoryTargetScope = factoryTargetScope;
 }
        protected override string ProcessToken(IsInRoleDto model, UserInfo accessingUser, Scope accessLevel)
        {
            var userInfo = UserController.Instance.GetCurrentUserInfo();
            var isInRole = userInfo.IsInRole(model.Name);
            var asString = isInRole ? Boolean.TrueString : Boolean.FalseString;

            return(asString);
        }
Beispiel #33
0
 public override Func <Scope, object> ToResolver(Scope topScope)
 {
     return(s => new SqlConnection(topScope.GetInstance <SqlServerSettings>().ConnectionString));
 }
Beispiel #34
0
        public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo accessingUser,
                                  Scope accessLevel, ref bool propertyNotFound)
        {
            string OutputFormat = string.Empty;

            if (format == string.Empty)
            {
                OutputFormat = "g";
            }
            else
            {
                OutputFormat = format;
            }

            string propName = propertyName.ToLowerInvariant();

            switch (propName)
            {
            case "roleid":
                return(PropertyAccess.FormatString(this.RoleID.ToString(), format));

            case "groupid":
                return(PropertyAccess.FormatString(this.RoleID.ToString(), format));

            case "status":
                return(PropertyAccess.FormatString(this.Status.ToString(), format));

            case "groupname":
                return(PropertyAccess.FormatString(this.RoleName, format));

            case "rolename":
                return(PropertyAccess.FormatString(this.RoleName, format));

            case "groupdescription":
                return(PropertyAccess.FormatString(this.Description, format));

            case "description":
                return(PropertyAccess.FormatString(this.Description, format));

            case "usercount":
                return(PropertyAccess.FormatString(this.UserCount.ToString(), format));

            case "street":
                return(PropertyAccess.FormatString(this.GetString("Street", string.Empty), format));

            case "city":
                return(PropertyAccess.FormatString(this.GetString("City", string.Empty), format));

            case "region":
                return(PropertyAccess.FormatString(this.GetString("Region", string.Empty), format));

            case "country":
                return(PropertyAccess.FormatString(this.GetString("Country", string.Empty), format));

            case "postalcode":
                return(PropertyAccess.FormatString(this.GetString("PostalCode", string.Empty), format));

            case "website":
                return(PropertyAccess.FormatString(this.GetString("Website", string.Empty), format));

            case "datecreated":
                return(PropertyAccess.FormatString(this.CreatedOnDate.ToString(), format));

            case "photourl":
                return(PropertyAccess.FormatString(this.FormatUrl(this.PhotoURL), format));

            case "stat_status":
                return(PropertyAccess.FormatString(this.GetString("stat_status", string.Empty), format));

            case "stat_photo":
                return(PropertyAccess.FormatString(this.GetString("stat_photo", string.Empty), format));

            case "stat_file":
                return(PropertyAccess.FormatString(this.GetString("stat_file", string.Empty), format));

            case "url":
                return(PropertyAccess.FormatString(this.FormatUrl(this.GetString("URL", string.Empty)), format));

            case "issystemrole":
                return(PropertyAccess.Boolean2LocalizedYesNo(this.IsSystemRole, formatProvider));

            case "grouptype":
                return(this.IsPublic ? "Public.Text" : "Private.Text");

            case "groupcreatorname":
                return(PropertyAccess.FormatString(this.GetString("GroupCreatorName", string.Empty), format));

            default:
                if (this.Settings.ContainsKey(propertyName))
                {
                    return(PropertyAccess.FormatString(this.GetString(propertyName, string.Empty), format));
                }

                propertyNotFound = true;
                return(string.Empty);
            }
        }
Beispiel #35
0
        public Task <Dictionary <string, object> > ProcessAsync(IntrospectionRequestValidationResult validationResult, Scope scope)
        {
            _logger.LogTrace("Creating introspection response");

            var response = new Dictionary <string, object>();

            if (validationResult.IsActive == false)
            {
                _logger.LogDebug("Creating introspection response for inactive token.");

                response.Add("active", false);
                return(Task.FromResult(response));
            }

            if (scope.AllowUnrestrictedIntrospection)
            {
                _logger.LogDebug("Creating unrestricted introspection response for active token.");

                response = validationResult.Claims.ToClaimsDictionary();
                response.Add("active", true);
            }
            else
            {
                _logger.LogDebug("Creating restricted introspection response for active token.");

                response = validationResult.Claims.Where(c => c.Type != JwtClaimTypes.Scope).ToClaimsDictionary();
                response.Add("active", true);
                response.Add("scope", new[] { scope.Name });
            }

            return(Task.FromResult(response));
        }
Beispiel #36
0
 public WebHostBuilderWrapper([NotNull] IWebHostBuilder webHostBuilder, Scope scope)
 {
     _webHostBuilderImplementation = webHostBuilder ?? throw new ArgumentNullException(nameof(webHostBuilder));
     _scope = scope;
 }
Beispiel #37
0
 public ParsedField(Scope scope, string type, string name)
 {
     Scope = scope;
     Type  = new ParsedType(type);
     Name  = name;
 }
Beispiel #38
0

        
Beispiel #39
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TokenReplace"/> class.
 /// creates a new TokenReplace object for custom context.
 /// </summary>
 /// <param name="accessLevel">Security level granted by the calling object.</param>
 /// <param name="moduleID">ID of the current module.</param>
 public TokenReplace(Scope accessLevel, int moduleID)
     : this(accessLevel, null, null, null, moduleID)
 {
 }
        protected override ClaimsIdentity GetOutputClaimsIdentity(ClaimsPrincipal principal, RequestSecurityToken request, Scope scope)
        {
            if (principal == null)
            {
                throw new InvalidRequestException("The caller's principal is null.");
            }

            ClaimsIdentity outputIdentity = (ClaimsIdentity)principal.Identity;

            //outputIdentity.AddClaim(new Claim(ClaimTypes.Email, "*****@*****.**"));
            //outputIdentity.AddClaim(new Claim(ClaimTypes.Surname, "Adams"));
            //outputIdentity.AddClaim(new Claim(ClaimTypes.Name, "Terry"));
            //outputIdentity.AddClaim(new Claim(ClaimTypes.Role, "developer"));
            //outputIdentity.AddClaim(new Claim("http://schemas.xmlsoap.org/claims/Group", "Sales"));
            //outputIdentity.AddClaim(new Claim("http://schemas.xmlsoap.org/claims/Group", "Marketing"));
            //   return (ClaimsIdentity)principal.Identity;

            return(outputIdentity);
        }
Beispiel #41
0
        public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo accessingUser, Scope currentScope, ref bool propertyNotFound)
        {
            string outputFormat = string.Empty;

            if (format == string.Empty)
            {
                outputFormat = "g";
            }

            if (currentScope == Scope.NoSettings)
            {
                propertyNotFound = true;
                return(PropertyAccess.ContentLocked);
            }

            propertyNotFound = true;
            string result   = string.Empty;
            bool   isPublic = true;

            switch (propertyName.ToLowerInvariant())
            {
            case "portalid":
                propertyNotFound = false;
                result           = this.PortalID.ToString(outputFormat, formatProvider);
                break;

            case "displayportalid":
                propertyNotFound = false;
                result           = this.OwnerPortalID.ToString(outputFormat, formatProvider);
                break;

            case "tabid":
                propertyNotFound = false;
                result           = this.TabID.ToString(outputFormat, formatProvider);
                break;

            case "tabmoduleid":
                propertyNotFound = false;
                result           = this.TabModuleID.ToString(outputFormat, formatProvider);
                break;

            case "moduleid":
                propertyNotFound = false;
                result           = this.ModuleID.ToString(outputFormat, formatProvider);
                break;

            case "moduledefid":
                isPublic         = false;
                propertyNotFound = false;
                result           = this.ModuleDefID.ToString(outputFormat, formatProvider);
                break;

            case "moduleorder":
                isPublic         = false;
                propertyNotFound = false;
                result           = this.ModuleOrder.ToString(outputFormat, formatProvider);
                break;

            case "panename":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.PaneName, format);
                break;

            case "moduletitle":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.ModuleTitle, format);
                break;

            case "cachetime":
                isPublic         = false;
                propertyNotFound = false;
                result           = this.CacheTime.ToString(outputFormat, formatProvider);
                break;

            case "cachemethod":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.CacheMethod, format);
                break;

            case "alignment":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.Alignment, format);
                break;

            case "color":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.Color, format);
                break;

            case "border":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.Border, format);
                break;

            case "iconfile":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.IconFile, format);
                break;

            case "alltabs":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(this.AllTabs, formatProvider);
                break;

            case "isdeleted":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(this.IsDeleted, formatProvider);
                break;

            case "header":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.Header, format);
                break;

            case "footer":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.Footer, format);
                break;

            case "startdate":
                isPublic         = false;
                propertyNotFound = false;
                result           = this.StartDate.ToString(outputFormat, formatProvider);
                break;

            case "enddate":
                isPublic         = false;
                propertyNotFound = false;
                result           = this.EndDate.ToString(outputFormat, formatProvider);
                break;

            case "containersrc":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.ContainerSrc, format);
                break;

            case "displaytitle":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(this.DisplayTitle, formatProvider);
                break;

            case "displayprint":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(this.DisplayPrint, formatProvider);
                break;

            case "displaysyndicate":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(this.DisplaySyndicate, formatProvider);
                break;

            case "iswebslice":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(this.IsWebSlice, formatProvider);
                break;

            case "webslicetitle":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.WebSliceTitle, format);
                break;

            case "websliceexpirydate":
                isPublic         = false;
                propertyNotFound = false;
                result           = this.WebSliceExpiryDate.ToString(outputFormat, formatProvider);
                break;

            case "webslicettl":
                isPublic         = false;
                propertyNotFound = false;
                result           = this.WebSliceTTL.ToString(outputFormat, formatProvider);
                break;

            case "inheritviewpermissions":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(this.InheritViewPermissions, formatProvider);
                break;

            case "isshareable":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(this.IsShareable, formatProvider);
                break;

            case "isshareableviewonly":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(this.IsShareableViewOnly, formatProvider);
                break;

            case "desktopmoduleid":
                isPublic         = false;
                propertyNotFound = false;
                result           = this.DesktopModuleID.ToString(outputFormat, formatProvider);
                break;

            case "friendlyname":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.DesktopModule.FriendlyName, format);
                break;

            case "foldername":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.DesktopModule.FolderName, format);
                break;

            case "description":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.DesktopModule.Description, format);
                break;

            case "version":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.DesktopModule.Version, format);
                break;

            case "ispremium":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(this.DesktopModule.IsPremium, formatProvider);
                break;

            case "isadmin":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(this.DesktopModule.IsAdmin, formatProvider);
                break;

            case "businesscontrollerclass":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.DesktopModule.BusinessControllerClass, format);
                break;

            case "modulename":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.DesktopModule.ModuleName, format);
                break;

            case "supportedfeatures":
                isPublic         = false;
                propertyNotFound = false;
                result           = this.DesktopModule.SupportedFeatures.ToString(outputFormat, formatProvider);
                break;

            case "compatibleversions":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.DesktopModule.CompatibleVersions, format);
                break;

            case "dependencies":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.DesktopModule.Dependencies, format);
                break;

            case "permissions":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.DesktopModule.Permissions, format);
                break;

            case "defaultcachetime":
                isPublic         = false;
                propertyNotFound = false;
                result           = this.ModuleDefinition.DefaultCacheTime.ToString(outputFormat, formatProvider);
                break;

            case "modulecontrolid":
                isPublic         = false;
                propertyNotFound = false;
                result           = this.ModuleControlId.ToString(outputFormat, formatProvider);
                break;

            case "controlsrc":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.ModuleControl.ControlSrc, format);
                break;

            case "controltitle":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.ModuleControl.ControlTitle, format);
                break;

            case "helpurl":
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.ModuleControl.HelpURL, format);
                break;

            case "supportspartialrendering":
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(this.ModuleControl.SupportsPartialRendering, formatProvider);
                break;

            case "containerpath":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.ContainerPath, format);
                break;

            case "panemoduleindex":
                isPublic         = false;
                propertyNotFound = false;
                result           = this.PaneModuleIndex.ToString(outputFormat, formatProvider);
                break;

            case "panemodulecount":
                isPublic         = false;
                propertyNotFound = false;
                result           = this.PaneModuleCount.ToString(outputFormat, formatProvider);
                break;

            case "isdefaultmodule":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(this.IsDefaultModule, formatProvider);
                break;

            case "allmodules":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(this.AllModules, formatProvider);
                break;

            case "isportable":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(this.DesktopModule.IsPortable, formatProvider);
                break;

            case "issearchable":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(this.DesktopModule.IsSearchable, formatProvider);
                break;

            case "isupgradeable":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.Boolean2LocalizedYesNo(this.DesktopModule.IsUpgradeable, formatProvider);
                break;

            case "adminpage":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.DesktopModule.AdminPage, format);
                break;

            case "hostpage":
                isPublic         = false;
                propertyNotFound = false;
                result           = PropertyAccess.FormatString(this.DesktopModule.HostPage, format);
                break;
            }

            if (!isPublic && currentScope != Scope.Debug)
            {
                propertyNotFound = true;
                result           = PropertyAccess.ContentLocked;
            }

            return(result);
        }
Beispiel #42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TokenReplace"/> class.
 /// creates a new TokenReplace object for custom context.
 /// </summary>
 /// <param name="accessLevel">Security level granted by the calling object.</param>
 /// <param name="language">Locale to be used for formatting etc.</param>
 /// <param name="portalSettings">PortalSettings to be used.</param>
 /// <param name="user">user, for which the properties shall be returned.</param>
 public TokenReplace(Scope accessLevel, string language, PortalSettings portalSettings, UserInfo user)
     : this(accessLevel, language, portalSettings, user, Null.NullInteger)
 {
 }
Beispiel #43
0
 /// <summary>
 /// Initializes a new <see cref="Type"/>.
 /// </summary>
 /// <param name="definedScope">The <see cref="Scope"/> this type defines associated members in.</param>
 public Type(Scope definedScope)
 {
     DefinedScope = definedScope;
 }
Beispiel #44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TokenReplace"/> class.
 /// creates a new TokenReplace object for custom context.
 /// </summary>
 /// <param name="accessLevel">Security level granted by the calling object.</param>
 public TokenReplace(Scope accessLevel)
     : this(accessLevel, null, null, null, Null.NullInteger)
 {
 }
 /// <summary>
 /// Creates a new instance of a user-defined function.
 /// </summary>
 /// <param name="prototype"> The next object in the prototype chain. </param>
 /// <param name="name"> The name of the function. </param>
 /// <param name="argumentNames"> The names of the arguments. </param>
 /// <param name="parentScope"> The scope at the point the function is declared. </param>
 /// <param name="bodyText"> The source code for the function body. </param>
 /// <param name="generatedMethod"> A delegate which represents the body of the function plus any dependencies. </param>
 /// <param name="strictMode"> <c>true</c> if the function body is strict mode; <c>false</c> otherwise. </param>
 /// <remarks> This is used by functions declared in JavaScript code (including getters and setters). </remarks>
 public UserDefinedFunction(ObjectInstance prototype, string name, IList <string> argumentNames, Scope parentScope, string bodyText, GeneratedMethod generatedMethod, bool strictMode)
     : base(prototype)
 {
     this.ArgumentsText   = string.Join(", ", argumentNames);
     this.ArgumentNames   = argumentNames;
     this.BodyText        = bodyText;
     this.generatedMethod = generatedMethod;
     this.body            = (FunctionDelegate)this.generatedMethod.GeneratedDelegate;
     this.ParentScope     = parentScope;
     this.StrictMode      = strictMode;
     InitProperties(name, argumentNames.Count);
 }
Beispiel #46
0
        public override object Resolve(Scope scope)
        {
            Func <T> func = scope.GetInstance <T>;

            return(func);
        }
        /// <summary>
        /// Registering an application
        /// </summary>
        /// <param name="instance">Instance to connect</param>
        /// <param name="appName">Name of your application</param>
        /// <param name="scope">The rights needed by your application</param>
        /// <param name="website">URL to the homepage of your app</param>
        /// <returns></returns>
        public static async Task <AppRegistration> CreateApp(string instance, string appName, Scope scope, string website = null, string redirectUri = null)
        {
            var data = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("client_name", appName),
                new KeyValuePair <string, string>("scopes", GetScopeParam(scope)),
            };

            if (string.IsNullOrEmpty(redirectUri))
            {
                data.Add(new KeyValuePair <string, string>("redirect_uris", "urn:ietf:wg:oauth:2.0:oob"));
            }
            else
            {
                data.Add(new KeyValuePair <string, string>("redirect_uris", redirectUri));
            }
            if (!string.IsNullOrEmpty(website))
            {
                data.Add(new KeyValuePair <string, string>("website", website));
            }

            string url      = $"https://{instance}/api/v1/apps";
            var    client   = new HttpClient();
            var    content  = new FormUrlEncodedContent(data);
            var    response = await client.PostAsync(url, content);

            var responseJson = await response.Content.ReadAsStringAsync();

            var appRegistration = JsonConvert.DeserializeObject <AppRegistration>(responseJson);

            appRegistration.Instance = instance;
            appRegistration.Scope    = scope;

            return(appRegistration);
        }
        public static Scope CreateDbCommandScope(Tracer tracer, IDbCommand command)
        {
            if (!tracer.Settings.IsIntegrationEnabled(AdoNetConstants.IntegrationId))
            {
                // integration disabled, don't create a scope, skip this trace
                return(null);
            }

            var commandType = command.GetType();

            if (tracer.Settings.AdoNetExcludedTypes.Count > 0 && tracer.Settings.AdoNetExcludedTypes.Contains(commandType.FullName))
            {
                // AdoNet type disabled, don't create a scope, skip this trace
                return(null);
            }

            Scope scope = null;

            try
            {
                string dbType = GetDbType(commandType.Namespace, commandType.Name);

                if (dbType == null)
                {
                    // don't create a scope, skip this trace
                    return(null);
                }

                Span parent = tracer.ActiveScope?.Span;

                if (parent != null &&
                    parent.Type == SpanTypes.Sql &&
                    parent.GetTag(Tags.DbType) == dbType &&
                    parent.ResourceName == command.CommandText)
                {
                    // we are already instrumenting this,
                    // don't instrument nested methods that belong to the same stacktrace
                    // e.g. ExecuteReader() -> ExecuteReader(commandBehavior)
                    return(null);
                }

                string serviceName   = tracer.Settings.GetServiceName(tracer, dbType);
                string operationName = $"{dbType}.query";

                var tags = new SqlTags();
                scope = tracer.StartActiveWithTags(operationName, tags: tags, serviceName: serviceName);
                var span = scope.Span;

                tags.DbType = dbType;

                span.AddTagsFromDbCommand(command);

                tags.SetAnalyticsSampleRate(AdoNetConstants.IntegrationId, tracer.Settings, enabledWithGlobalSetting: false);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Error creating or populating scope.");
            }

            return(scope);
        }
Beispiel #49
0
        internal static IValue Compare(List <IValue> list, Scope scope)
        {
            IValue first = list.First();

            return(first.MetaType.Compare.Invoke(list, scope).First());
        }
 /// <summary>
 /// Creates a new instance of a user-defined function.
 /// </summary>
 /// <param name="prototype"> The next object in the prototype chain. </param>
 /// <param name="name"> The name of the function. </param>
 /// <param name="argumentNames"> The names of the arguments. </param>
 /// <param name="parentScope"> The scope at the point the function is declared. </param>
 /// <param name="bodyText"> The source code for the function body. </param>
 /// <param name="body"> A delegate which represents the body of the function. </param>
 /// <param name="strictMode"> <c>true</c> if the function body is strict mode; <c>false</c> otherwise. </param>
 /// <remarks> This is used by <c>arguments</c>. </remarks>
 internal UserDefinedFunction(ObjectInstance prototype, string name, IList <string> argumentNames, Scope parentScope, string bodyText, FunctionDelegate body, bool strictMode)
     : base(prototype)
 {
     this.ArgumentsText   = string.Join(", ", argumentNames);
     this.ArgumentNames   = argumentNames;
     this.BodyText        = bodyText;
     this.generatedMethod = new GeneratedMethod(body, null);
     this.body            = body;
     this.ParentScope     = parentScope;
     this.StrictMode      = strictMode;
     InitProperties(name, argumentNames.Count);
 }
 public static EngineResult Evaluate(IfStatement conditional, Scope scope) =>
 Evaluate(conditional.Predicate, NullArgument.It, scope) ? Evaluate(conditional.ThenStatement, scope) :
 conditional.ElseStatement != null?Evaluate(conditional.ElseStatement, scope) :
     null;
        /** ****************************************************************************************
         * Searches value in the actual scope. While not found, moves walk state to next outer
         * and continues there.
         * @return The next object found in the current or any next outer scope.
         ******************************************************************************************/
        public T  Walk()
        {
            while (walking)
            {
                switch (actScope)
                {
                case Scope.ThreadInner:
                {
                    // initialize
                    if (walkNextThreadIdx == -2)
                    {
                        walkNextThreadIdx = -1;
                        if (threadInnerStore.Count != 0)
                        {
                            walkThreadValues = null;
                            threadInnerStore.TryGetValue(scopeInfo.GetThread(), out walkThreadValues);
                            if (walkThreadValues != null)
                            {
                                walkNextThreadIdx = walkThreadValues.Count;
                            }
                        }
                    }

                    // return next inner thread object (walkNext keeps being ThreadInner)
                    if (walkNextThreadIdx > 0)
                    {
                        walkNextThreadIdx--;
                        return(walkThreadValues[walkNextThreadIdx]);
                    }

                    // next scope is Method
                    actScope = Scope.Method;

                    // if we have a valid 'local object' return this first
                    if (walkLocalObject != null)
                    {
                        return(walkLocalObject);
                    }
                }
                break;

                case Scope.Path:
                case Scope.Filename:
                case Scope.Method:
                {
                    if (lazyLanguageNode)
                    {
                        getPathMapNode(false);
                    }

                    while (actPathMapNode != null)
                    {
                        T actValue = actPathMapNode.Value;
                        actPathMapNode = actPathMapNode.Parent;
                        if (actValue != null)
                        {
                            return(actValue);
                        }
                    }

                    actScope          = Scope.ThreadOuter;
                    walkNextThreadIdx = -2;
                }
                break;

                case Scope.ThreadOuter:
                {
                    // initialize
                    if (walkNextThreadIdx == -2)
                    {
                        if (threadOuterStore.Count != 0)
                        {
                            walkThreadValues = null;
                            threadOuterStore.TryGetValue(scopeInfo.GetThread(), out walkThreadValues);
                            if (walkThreadValues != null)
                            {
                                walkNextThreadIdx = walkThreadValues.Count;
                            }
                        }
                    }

                    // return next outer thread object (walkNext keeps being ThreadOuter)
                    if (walkNextThreadIdx > 0)
                    {
                        walkNextThreadIdx--;
                        return(walkThreadValues[walkNextThreadIdx]);
                    }

                    // next scope is Global
                    actScope = Scope.Global;
                }
                break;

                case Scope.Global:
                {
                    walking = false;
                    return(globalStore);
                }
                }
            }

            return(default(T));
        }
Beispiel #53
0
 public override Operand Eval(Scope scope) => this;
Beispiel #54
0
        public string GetProperty(string propertyName, string format, System.Globalization.CultureInfo formatProvider, Entities.Users.UserInfo accessingUser, Scope accessLevel, ref bool propertyNotFound)
        {
            string OutputFormat = string.Empty;

            if (format == string.Empty)
            {
                OutputFormat = "g";
            }
            else
            {
                OutputFormat = format;
            }
            propertyName = propertyName.ToLowerInvariant();
            switch (propertyName)
            {
            case "journalid":
                return(PropertyAccess.FormatString(JournalId.ToString(), format));

            case "journaltypeid":
                return(PropertyAccess.FormatString(JournalTypeId.ToString(), format));

            case "profileid":
                return(PropertyAccess.FormatString(ProfileId.ToString(), format));

            case "socialgroupid":
                return(PropertyAccess.FormatString(SocialGroupId.ToString(), format));

            case "datecreated":
                return(PropertyAccess.FormatString(DateCreated.ToString(), format));

            case "title":
                return(PropertyAccess.FormatString(Title, format));

            case "summary":
                return(PropertyAccess.FormatString(Summary, format));

            case "body":
                return(PropertyAccess.FormatString(Body, format));

            case "timeframe":
                return(PropertyAccess.FormatString(TimeFrame, format));

            case "isdeleted":
                return(IsDeleted.ToString());
            }

            propertyNotFound = true;
            return(string.Empty);
        }
Beispiel #55
0
 public override object Resolve(Scope scope)
 {
     return(new SqlConnection(scope.GetInstance <SqlServerSettings>().ConnectionString));
 }
Beispiel #56
0
        public Factorial()
        {
            var ifBlockScope = Scope.CreateAndBuild(new List <IsStatic> {
            });
            var elseBlock    = Scope.CreateAndBuild(new List <IsStatic> {
            });

            var inputKey = new NameKey("input");
            var input    = MemberDefinition.CreateAndBuild(inputKey, new NumberType(), Access.ReadWrite);

            var facKey = new NameKey("fac");
            var fac    = MemberDefinition.CreateAndBuild(facKey, MethodType.CreateAndBuild(new NumberType(), new NumberType()), Access.ReadWrite);

            var methodScope = Scope.CreateAndBuild(new List <IsStatic> {
                new IsStatic(input, false)
            });

            RootScope =
                Model.Instantiated.RootScope.CreateAndBuild(
                    Scope.CreateAndBuild(
                        new List <IsStatic> {
                new IsStatic(MemberDefinition.CreateAndBuild(facKey, MethodType.CreateAndBuild(
                                                                 new NumberType(),
                                                                 new NumberType()), Access.ReadWrite), false)
            }),
                    new [] {
                AssignOperation.CreateAndBuild(
                    MethodDefinition.CreateAndBuild(
                        new NumberType(),
                        input,
                        methodScope,
                        new ICodeElement[] {
                    ElseOperation.CreateAndBuild(
                        IfOperation.CreateAndBuild(
                            LessThanOperation.CreateAndBuild(
                                MemberReference.CreateAndBuild(input),
                                ConstantNumber.CreateAndBuild(2)),
                            BlockDefinition.CreateAndBuild(
                                ifBlockScope,
                                new ICodeElement[] {
                        ReturnOperation.CreateAndBuild(
                            ConstantNumber.CreateAndBuild(1))
                    },
                                Array.Empty <ICodeElement>())),
                        BlockDefinition.CreateAndBuild(
                            elseBlock,
                            new ICodeElement[] {
                        ReturnOperation.CreateAndBuild(
                            MultiplyOperation.CreateAndBuild(
                                NextCallOperation.CreateAndBuild(
                                    SubtractOperation.CreateAndBuild(
                                        MemberReference.CreateAndBuild(input),
                                        ConstantNumber.CreateAndBuild(1)),
                                    MemberReference.CreateAndBuild(fac)),
                                MemberReference.CreateAndBuild(input)))
                    },
                            Array.Empty <ICodeElement>()))
                },
                        Array.Empty <ICodeElement>()),
                    MemberReference.CreateAndBuild(fac)
                    )
            },
                    EntryPointDefinition.CreateAndBuild(new EmptyType(), MemberDefinition.CreateAndBuild(new NameKey("input"), new NumberType(), Access.ReadWrite), Scope.CreateAndBuild(Array.Empty <IsStatic>()), Array.Empty <ICodeElement>(), Array.Empty <ICodeElement>())
                    );
        }
 /// <summary>
 ///     Connects the specified scope.
 /// </summary>
 internal void Connect(Scope scope)
 {
     this.scope = scope;
     AttachEvents();
 }
Beispiel #58
0
        private static Scope CreateScope(RequestContext requestContext)
        {
            var requestMessage = requestContext?.RequestMessage;

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

            var tracer = Tracer.Instance;

            if (!tracer.Settings.IsIntegrationEnabled(IntegrationName))
            {
                // integration disabled, don't create a scope, skip this trace
                return(null);
            }

            Scope scope = null;

            try
            {
                SpanContext propagatedContext = null;
                string      host       = null;
                string      httpMethod = null;

                if (requestMessage.Properties.TryGetValue("httpRequest", out var httpRequestProperty) &&
                    httpRequestProperty is HttpRequestMessageProperty httpRequestMessageProperty)
                {
                    // we're using an http transport
                    host       = httpRequestMessageProperty.Headers[HttpRequestHeader.Host];
                    httpMethod = httpRequestMessageProperty.Method?.ToUpperInvariant();

                    // try to extract propagated context values from http headers
                    if (tracer.ActiveScope == null)
                    {
                        try
                        {
                            var headers = httpRequestMessageProperty.Headers.Wrap();
                            propagatedContext = tracer.Propagator.Extract(headers);
                        }
                        catch (Exception ex)
                        {
                            Log.Error(ex, "Error extracting propagated HTTP headers.");
                        }
                    }
                }

                var operationNameSuffix = requestMessage.Headers.Action ?? requestMessage.Headers.To?.LocalPath;
                var operationName       = !string.IsNullOrEmpty(operationNameSuffix)
                    ? "wcf.request " + operationNameSuffix
                    : "wcf.request";

                scope = tracer.StartActive(operationName, propagatedContext);
                var span = scope.Span;

                span.DecorateWebServerSpan(
                    resourceName: null,
                    httpMethod,
                    host,
                    httpUrl: requestMessage.Headers.To?.AbsoluteUri);

                // set analytics sample rate if enabled
                var analyticsSampleRate = tracer.Settings.GetIntegrationAnalyticsSampleRate(IntegrationName, enabledWithGlobalSetting: true);
                span.SetMetric(Tags.Analytics, analyticsSampleRate);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Error creating or populating scope.");
            }

            // always returns the scope, even if it's null
            return(scope);
        }
        protected override IClaimsIdentity GetOutputClaimsIdentity(IClaimsPrincipal principal,
            RequestSecurityToken request, Scope scope)
        {
            if (null == principal)
            {
                throw new ArgumentNullException("principal");
            }
            var outputIdentity = new ClaimsIdentity();

            var userName = principal.Identity.Name;
            using (var db = new StsContext())
            {
                var webUser = db.WebUsers.Single(w => w.Username == userName);
                foreach (var requestClaim in request.Claims)
                {
                    var value = GetValueForClaimRequest(requestClaim, webUser);
                    if (value != null)
                    {
                        outputIdentity.Claims.Add(new Claim(requestClaim.ClaimType, value));
                    }
                }
                if (outputIdentity.Claims.All(c => c.ClaimType != Security.ClaimTypes.Name))
                {
                    outputIdentity.Claims.Add(new Claim(Security.ClaimTypes.Name, webUser.Username));
                }
                if (outputIdentity.Claims.All(c => c.ClaimType != Security.ClaimTypes.Role))
                {
                    outputIdentity.Claims.Add(new Claim(Security.ClaimTypes.Role, webUser.Role));
                }
            }
            return outputIdentity;
        }
        protected override IClaimsIdentity GetOutputClaimsIdentity(IClaimsPrincipal principal, RequestSecurityToken request, Scope scope)
        {
            var outputIdentity = new ClaimsIdentity();

            if (null == principal)
            {
                throw new InvalidRequestException("The caller's principal is null.");
            }

            switch (principal.Identity.Name.ToUpperInvariant())
            {
                // In a production environment, all the information that will be added
                // as claims should be read from the authenticated Windows Principal.
                // The following lines are hardcoded because windows integrated
                // authentication is disabled.
                case "ADATUM\\JOHNDOE":
                    outputIdentity.Claims.AddRange(new List<Claim>
                       {
                           new Claim(System.IdentityModel.Claims.ClaimTypes.Name, "ADATUM\\johndoe"),
                           new Claim(AllOrganizations.ClaimTypes.Group, Adatum.Groups.DomainUsers),
                           new Claim(AllOrganizations.ClaimTypes.Group, Adatum.Groups.MarketingManagers)
                       });
                    break;
            }

            return outputIdentity;
        }