本文整理汇总了C#中Scope类的典型用法代码示例。如果您正苦于以下问题:C# Scope类的具体用法?C# Scope怎么用?C# Scope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Scope类属于命名空间,在下文中一共展示了Scope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProperty
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;
}
}
示例2: ExpansionContext
private ExpansionContext(Stack<MethodBase> stack, Scope scope, NameGenerator names, IEnumerable<KeyValuePair<Sym, Expression>> env)
{
Stack = stack;
Scope = scope;
Names = names;
Env = env.ToDictionary();
}
示例3: GetProperty
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;
}
}
示例4: Scope
// 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)) {}
示例5: Execute
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;
}
}
示例6: Repository
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());
}
示例7: Scope
public Scope(BodyType bodyType, Scope parent, ReadOnlyArray<string> parameters)
{
_bodyType = bodyType;
Parent = parent;
_parameters = parameters;
_rootScope = parent != null ? parent._rootScope : this;
}
示例8: GetProperty
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;
}
}
示例9: GetProperty
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;
}
示例10: IncludeToken
private IncludeToken(Token parent, Scope scope, Span span, PreprocessorToken prepToken, string fileName, bool searchFileDir)
: base(parent, scope, span)
{
_prepToken = prepToken;
_fileName = fileName;
_searchFileDir = searchFileDir;
}
示例11: GeneratedCodeVisitor
public GeneratedCodeVisitor(SourceBuilder output, Dictionary<string, object> globalSymbols, NullBehaviour nullBehaviour)
{
_nullBehaviour = nullBehaviour;
_source = output;
_scope = new Scope(new Scope(null) { Variables = globalSymbols });
}
示例12: ProcessContract
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;
}
示例13: ProvisionAccessTokenAsync_AssertionTokenIsSigned
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 );
}
示例14: SetRequestMessage
/// <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();
}
示例15: NativeCallContext
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));
}
}