internal LastAccessTimeTrackingPolicy(bool enable, Name?name, int?trackingGranularityInDays, IList <string> blobType) { Enable = enable; Name = name; TrackingGranularityInDays = trackingGranularityInDays; BlobType = blobType; }
protected BindingSymbol(Symbol containingSymbol, Name?name, bool isMutableBinding, DataType dataType) : base(containingSymbol, name) { Package = containingSymbol.Package; Name = name; IsMutableBinding = isMutableBinding; DataType = dataType; }
public int CompareTo(Name?other) { if (other == null || other.GetType() != typeof(Name)) { return(1); } return(string.Compare(Value, other.Value, StringComparison.Ordinal)); }
private string PrintName(Name?name) { if (name == null) { return(string.Empty); } return(name.Value); }
public static Diagnostic SharedValueDoesNotLiveLongEnough( CodeFile file, TextSpan span, Name?variable) { var msg = variable is null ? "Shared value does not live long enough" : $"Value shared by `{variable}` does not live long enough"; return(new Diagnostic(file, span, DiagnosticLevel.FatalCompilationError, DiagnosticPhase.Analysis, 4001, msg)); }
public override void WriteJson(JsonWriter writer, Name?value, JsonSerializer serializer) { if (string.IsNullOrWhiteSpace(value?.Overridden)) { writer.WriteValue(value?.Value + string.Empty); } else { writer.WriteValue($"{value.Singular.Value}[{value.Value}]"); } }
public static object ParseWrapper(Func <object> parser, Type targetType, Name?argumentName = null) { try { return(parser()); } catch (Exception ex) { throw new ArgumentParsingException(ex.Message, targetType, argumentName); } }
public ConstructorSymbol( ObjectTypeSymbol containingSymbol, Name?name, FixedList <DataType> parameterDataTypes, FixedSet <ReachabilityAnnotation>?reachabilityAnnotations = null) : base(containingSymbol, name, parameterDataTypes, containingSymbol.DeclaresDataType.ToConstructorReturn(), reachabilityAnnotations ?? FixedSet <ReachabilityAnnotation> .Empty) { ContainingSymbol = containingSymbol; ReturnDataType = containingSymbol.DeclaresDataType.ToConstructorReturn(); }
public bool Equals(Name?other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Value == other.Value); }
private Module(string company, string project, Name?feature = null, string?defaultSchema = null) : base(project) { if (company is null) { throw new ArgumentNullException(nameof(company)); } Company = company.Trim().Dehumanize().Pascalize(); Feature = feature; DefaultSchema = defaultSchema; }
public NewObjectExpressionSyntax( TextSpan span, ITypeNameSyntax typeSyntax, Name?constructorName, TextSpan?constructorNameSpan, FixedList <IArgumentSyntax> arguments) : base(span, ExpressionSemantics.Acquire) { Type = typeSyntax; Arguments = arguments; ConstructorName = constructorName; ConstructorNameSpan = constructorNameSpan; }
protected MemberDeclarationSyntax( IClassDeclarationSyntax declaringClass, TextSpan span, CodeFile file, IAccessModifierToken?accessModifier, TextSpan nameSpan, Name?name, IPromise <Symbol> symbol) : base(span, file, name, nameSpan, symbol) { DeclaringClass = declaringClass; AccessModifier = accessModifier; }
protected InvocableSymbol( Symbol containingSymbol, Name?name, FixedList <DataType> parameterDataTypes, DataType returnDataType, FixedSet <ReachabilityAnnotation> reachabilityAnnotations) : base(containingSymbol, name) { ContainingSymbol = containingSymbol; Name = name; ParameterDataTypes = parameterDataTypes; ReturnDataType = returnDataType; ReachabilityAnnotations = reachabilityAnnotations; }
public override Name ReadJson(JsonReader reader, Type objectType, Name?existingValue, bool hasExistingValue, JsonSerializer serializer) { if (reader is null) { throw new ArgumentNullException(nameof(reader)); } var s = (string?)reader.Value; if (hasExistingValue && existingValue is not null) { existingValue.SetName(s); return(existingValue); } return(new Name(s)); }
protected InvocableDeclarationSyntax( TextSpan span, CodeFile file, IAccessModifierToken?accessModifier, TextSpan nameSpan, Name?name, IEnumerable <IConstructorParameterSyntax> parameters, IReachabilityAnnotationsSyntax reachabilityAnnotations, IPromise <InvocableSymbol> symbol) : base(span, file, name, nameSpan, symbol) { AccessModifier = accessModifier; Parameters = parameters.ToFixedList(); ReachabilityAnnotations = reachabilityAnnotations; Symbol = symbol; }
public string ToString(Name?memberName, bool instance) { StringBuilder result = new StringBuilder(); for (int i = 0; i < namespaces.Length; i++) { result.Append(namespaces[i]); result.Append(Separator); } result.Append(Name); if (memberName.HasValue) { result.Append(instance ? "->" : "::"); result.Append(memberName.Value.ToString()); } return(result.ToString()); }
public static T ValidateIfRequired <T>(this T value, IValidation?validation, Name?argumentName = null) { if (validation != null && !validation.IsValid(value !, out var errorMessage)) { if (string.IsNullOrEmpty(errorMessage)) { ThrowValidationError("Validation failed!"); } else { ThrowValidationError($"Validation failed: {errorMessage}"); } void ThrowValidationError(string message) => throw new ArgumentParsingException(message, typeof(T), argumentName); } return(value); }
public ConstructorDeclarationSyntax( IClassDeclarationSyntax declaringType, TextSpan span, CodeFile file, IAccessModifierToken?accessModifier, TextSpan nameSpan, Name?name, ISelfParameterSyntax implicitSelfParameter, FixedList <IConstructorParameterSyntax> parameters, IReachabilityAnnotationsSyntax reachabilityAnnotations, IBodySyntax body) : base(span, file, accessModifier, nameSpan, name, parameters, reachabilityAnnotations, new AcyclicPromise <ConstructorSymbol>()) { DeclaringClass = declaringType; ImplicitSelfParameter = implicitSelfParameter; Parameters = parameters; Body = body; Symbol = (AcyclicPromise <ConstructorSymbol>)base.Symbol; }
get => (!string.IsNullOrEmpty(Name?.Trim()));
public bool Equals(Name?input) { return(OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual); }
public ArgumentMissingException(string description, Type type, Name?argumentName = null) { Description = description; Type = type; ArgumentName = argumentName; }
public NamedParameterNameSyntax(TextSpan span, Name?name) : base(span) { Name = name; }
public IOutput Create() { var sb = new StringBuilder(); var m = _module.Models.Where(m => m.Behaviours.Any()).Select(m => new { Model = m, Behaviour = m.Behaviours.First() }).FirstOrDefault(); Name? request=null; if(m is not null) { if(m.Behaviour.Request is null) { request = new Name($"{m.Model.Name}{m.Behaviour.Name}Request"); } else { request = m.Behaviour.Request.Name; } sb.Al($"using {_module.Namespace}.BusinessLogic.{m.Model.Name};"); sb.Al($"using {_module.Namespace}.BusinessLogic.{m.Model.Name}.{m.Behaviour.Name};"); } sb.Al($"using {_module.Namespace}.Common.EntityTypes;"); sb.Al($"using {_module.Namespace}.DataAccess.Rcms;"); sb.Al($"using {_module.Namespace}.DataAccess.Nevdis;"); sb.B(); sb.Al($"namespace {_module.Namespace}.Application"); sb.Al("{"); sb.I(1).Al("public class Startup"); sb.I(1).Al("{"); sb.I(2).Al("public Startup(IConfiguration configuration)"); sb.I(2).Al("{"); sb.I(3).Al("Configuration = configuration;"); sb.I(2).Al("}"); sb.B(); sb.I(2).Al("public IConfiguration Configuration { get; }"); sb.B(); sb.I(2).Al("public void ConfigureServices(IServiceCollection services)"); sb.I(2).Al("{"); if(request is not null) { sb.I(3).Al($"services.AddMediatR(typeof({request}).Assembly);"); sb.B(); } sb.I(3).Al("services.AddControllers()"); sb.I(4).Al(".ConfigureApiBehaviorOptions(options =>"); sb.I(4).Al("{"); sb.I(5).Al("options.InvalidModelStateResponseFactory = ModelStateValidator.ValidateModelState;"); sb.I(4).Al("})"); if(request is not null) { sb.I(4).Al(".AddFluentValidation(options =>"); sb.I(4).Al("{"); sb.I(5).Al($"options.RegisterValidatorsFromAssemblyContaining<{request}Validator>();"); sb.I(4).Al("});"); } sb.B(); sb.I(3).Al("//todo: Add your service registrations here"); sb.B(); sb.I(3).Al("services.AddSwaggerGen(c =>"); sb.I(3).Al("{"); sb.I(4).Al($"c.SwaggerDoc(\"v1\", new OpenApiInfo {{ Title = \"{_module.Company} {_module.Project.Singular.Display}\", Version = \"v1\" }});"); sb.I(3).Al("});"); sb.I(2).Al("}"); sb.B(); sb.I(2).Al("public void Configure(IApplicationBuilder app, IWebHostEnvironment env)"); sb.I(2).Al("{"); sb.I(3).Al("if (env.IsDevelopment())"); sb.I(3).Al("{"); sb.I(4).Al("app.UseDeveloperExceptionPage();"); sb.I(4).Al("app.UseSwagger();"); sb.I(4).Al($"app.UseSwaggerUI(c => c.SwaggerEndpoint(\"/swagger/v1/swagger.json\", \"{_module.Company} {_module.Project.Singular.Display} v1\"));"); sb.I(3).Al("}"); sb.B(); sb.I(3).Al("app.UseMiddleware<ExceptionHandler>();"); sb.I(3).Al("app.UseHttpsRedirection();"); sb.I(3).Al("app.UseRouting();"); sb.I(3).Al("app.UseAuthorization();"); sb.I(3).Al("app.UseEndpoints(endpoints =>"); sb.I(3).Al("{"); sb.I(4).Al("endpoints.MapControllers();"); sb.I(3).Al("});"); sb.I(2).Al("}"); sb.I(1).Al("}"); sb.B(); sb.I(1).Al("public class ModelStateValidator"); sb.I(1).Al("{"); sb.I(2).Al("public static IActionResult ValidateModelState(ActionContext context)"); sb.I(2).Al("{"); sb.I(3).Al("(string fieldName, ModelStateEntry entry) = context.ModelState.First(x => x.Value.Errors.Count > 0);"); sb.I(3).Al("string errorSerialized = entry.Errors.First().ErrorMessage;"); sb.B(); sb.I(3).Al("Error error = Error.Deserialize(errorSerialized);"); sb.I(3).Al("Envelope envelope = Envelope.Error(error, fieldName);"); sb.I(3).Al("var envelopeResult = new EnvelopeResult(envelope, HttpStatusCode.BadRequest);"); sb.B(); sb.I(3).Al("return envelopeResult;"); sb.I(2).Al("}"); sb.I(1).Al("}"); sb.Al("}"); return new File("Startup.cs", sb.ToString()); }
public User(ExternalUserId externalUserId, Name?name, CustomerId?customerId) { this.ExternalUserId = externalUserId; this.Name = name; this.CustomerId = customerId; }
protected ParameterSyntax(TextSpan span, Name?name) : base(span) { Name = name; Unused = name?.Text.StartsWith('_') ?? false; }
public ActionResult Index(Name?name, SignText?signText, EncText?encText, Guid?userId) { Guid token = CheckSessionAuthState(CurrentUser, _authService); if (token == Guid.Empty) { return(RedirectToAction("LogOff", "Account")); } var navigation = new MyNavigation(); if (userId != null && userId != Guid.Empty) { navigation.Navigations.Add(new NavElement { Depth = 1, Name = "Администрирование", Action = "Index", Controller = "Administration", IsUrl = true }); UserInfoResponse responseUser = _authService.GetUserDataByID((Guid)userId); navigation.Navigations.Add(new NavElement { Depth = 3, Name = responseUser.User.Name, IsUrl = false }); navigation.Navigations.Add(new NavElement { Depth = 4, Name = "Шаблоны настроек", IsUrl = false }); } else { navigation.Navigations.Add(new NavElement { Depth = 1, Name = "Шаблоны настроек", Action = "Index", Controller = "Settings", IsUrl = false }); } ViewBag.nav = navigation.Navigations.OrderBy(x => x.Depth).ToList(); var userInfo = (UserInfo)Session["userInfo"]; ViewBag.userInfo = userInfo; UserProfilesResponse response = _cryptxService.GetUserProfiles(userId == null ? Guid.Empty : (Guid)userId, token); if (response.Exception != null) { throw response.Exception; } switch (name) { case Name.ASC: signText = null; encText = null; ViewBag.name = name; ViewBag.signText = null; ViewBag.encText = null; response.UserProfileList = response.UserProfileList.OrderBy(x => x.Name).ToList(); break; case Name.DESC: signText = null; encText = null; ViewBag.name = name; ViewBag.signText = null; ViewBag.encText = null; response.UserProfileList = response.UserProfileList.OrderByDescending(x => x.Name).ToList(); break; } switch (signText) { case SignText.ASC: name = null; encText = null; ViewBag.name = null; ViewBag.signText = signText; ViewBag.encText = null; response.UserProfileList = response.UserProfileList.OrderBy(x => x.SignText).ToList(); break; case SignText.DESC: name = null; encText = null; ViewBag.name = null; ViewBag.signText = signText; ViewBag.encText = null; response.UserProfileList = response.UserProfileList.OrderByDescending(x => x.SignText).ToList(); break; } switch (encText) { case EncText.ASC: name = null; signText = null; ViewBag.name = null; ViewBag.signText = null; ViewBag.encText = encText; response.UserProfileList = response.UserProfileList.OrderBy(x => x.EncryptionText).ToList(); break; case EncText.DESC: name = null; signText = null; ViewBag.name = null; ViewBag.signText = null; ViewBag.encText = encText; response.UserProfileList = response.UserProfileList.OrderByDescending(x => x.EncryptionText).ToList(); break; } ViewBag.UserId = userId == null ? Guid.Empty : (Guid)userId; return(View(response.UserProfileList)); }
private static VCard?ToVCard(Contact?contact) { if (contact is null) { return(null); } contact.Clean(); if (contact.IsEmpty) { return(null); } var vcard = new VCard(); bool writeAdrWork = true; Work?work = contact.Work; Address?adrHome = contact.AddressHome; if (adrHome != null) { var homeAdr = new VC::AddressProperty(street: adrHome.Street, locality: adrHome.City, postalCode: adrHome.PostalCode, region: adrHome.State, country: adrHome.Country); vcard.Addresses = homeAdr; homeAdr.Parameters.AddressType = VC::Enums.AddressTypes.Dom | VC::Enums.AddressTypes.Intl | VC::Enums.AddressTypes.Parcel | VC::Enums.AddressTypes.Postal; if (adrHome == work?.AddressWork) { homeAdr.Parameters.PropertyClass = VC::Enums.PropertyClassTypes.Home | VC::Enums.PropertyClassTypes.Work; writeAdrWork = false; } else { homeAdr.Parameters.PropertyClass = VC::Enums.PropertyClassTypes.Home; } homeAdr.Parameters.Label = BuildAddressLabel(adrHome); } if (work != null) { Address?adrWork = work.AddressWork; if (writeAdrWork && adrWork != null) { var workAdr = new VC::AddressProperty(street: adrWork.Street, locality: adrWork.City, postalCode: adrWork.PostalCode, region: adrWork.State, country: adrWork.Country); IEnumerable <VC::AddressProperty?>?addresses = vcard.Addresses; if (addresses is null) { vcard.Addresses = workAdr; } else if (addresses is VC::AddressProperty homeAdr) { vcard.Addresses = new VC::AddressProperty[] { homeAdr, workAdr }; } workAdr.Parameters.AddressType = VC::Enums.AddressTypes.Dom | VC::Enums.AddressTypes.Intl | VC::Enums.AddressTypes.Parcel | VC::Enums.AddressTypes.Postal; workAdr.Parameters.PropertyClass = VC::Enums.PropertyClassTypes.Work; workAdr.Parameters.Label = BuildAddressLabel(adrWork); } if (work.Company != null || work.Department != null || work.Office != null) { vcard.Organizations = new VC::OrganizationProperty(work.Company, new string?[] { work.Department, work.Office }); } if (work.JobTitle != null) { vcard.Titles = new VC::TextProperty(work.JobTitle); } } var comment = contact.Comment; if (comment != null) { vcard.Notes = new VC::TextProperty(comment); } var displayName = contact.DisplayName; if (displayName != null) { vcard.DisplayNames = new VC::TextProperty(displayName); } IEnumerable <string?>?emails = contact.EmailAddresses; if (emails != null) { var emailProps = new List <VC::TextProperty>(); vcard.EmailAddresses = emailProps; int counter = 1; foreach (var mailAddress in emails) { Debug.Assert(mailAddress != null); var mailProp = new VC::TextProperty(mailAddress); emailProps.Add(mailProp); mailProp.Parameters.EmailType = VC::Enums.EmailType.SMTP; mailProp.Parameters.Preference = counter++; } } var webPersonal = contact.WebPagePersonal; var webWork = contact.WebPageWork; bool writeWebWork = true; if (webPersonal != null) { var urlHomeProp = new VC::TextProperty(webPersonal); vcard.URLs = urlHomeProp; if (webPersonal == webWork) { urlHomeProp.Parameters.PropertyClass = VC::Enums.PropertyClassTypes.Home | VC::Enums.PropertyClassTypes.Work; writeWebWork = false; } else { urlHomeProp.Parameters.PropertyClass = VC::Enums.PropertyClassTypes.Home; } } if (writeWebWork && webWork != null) { var urlWork = new VC::TextProperty(webWork); urlWork.Parameters.PropertyClass = VC::Enums.PropertyClassTypes.Work; IEnumerable <VC::TextProperty?>?urls = vcard.URLs; if (urls is null) { vcard.URLs = urlWork; } else if (urls is VC::TextProperty urlHome) { vcard.URLs = new VC::TextProperty[] { urlHome, urlWork }; } } IEnumerable <string?>?impps = contact.InstantMessengerHandles; if (impps != null) { var imppProps = new List <VC::TextProperty>(); vcard.InstantMessengerHandles = imppProps; int counter = 1; foreach (var imppAddress in impps) { Debug.Assert(imppAddress != null); var imppProp = new VC::TextProperty(imppAddress); imppProps.Add(imppProp); imppProp.Parameters.Preference = counter++; } } Person?person = contact.Person; if (person != null) { DateTime?bday = person.BirthDay; if (bday.HasValue) { vcard.BirthDayViews = new VC::DateTimeOffsetProperty(bday.Value); } Name?name = person.Name; if (name != null) { vcard.NameViews = new VC::NameProperty(name.LastName, name.FirstName, name.MiddleName, name.Prefix, name.Suffix); } Sex gender = person.Gender; if (gender != Sex.Unspecified) { vcard.GenderViews = new VC::GenderProperty( gender == Sex.Female ? VC::Enums.VCdSex.Female : VC::Enums.VCdSex.Male); } var nickName = person.NickName; if (nickName != null) { vcard.NickNames = new VC::StringCollectionProperty(nickName); } var spouseName = person.Spouse; if (spouseName != null) { vcard.Relations = new VC::RelationTextProperty( spouseName, VC::Enums.RelationTypes.Spouse); } DateTime?anniversary = person.Anniversary; if (anniversary.HasValue) { vcard.AnniversaryViews = new VC::DateTimeOffsetProperty(anniversary.Value); } } IEnumerable <PhoneNumber?>?phones = contact.PhoneNumbers; if (phones != null) { var phoneProps = new List <VC::TextProperty>(); vcard.PhoneNumbers = phoneProps; foreach (PhoneNumber?number in phones) { Debug.Assert(number != null); var phoneProp = new VC::TextProperty(number !.Value); phoneProps.Add(phoneProp); VC::Enums.TelTypes?telType = null; if (number.IsMobile) { telType = VC::Enums.TelTypes.Cell; } if (number.IsFax) { telType = telType.Set(VC.Enums.TelTypes.Fax); } phoneProp.Parameters.TelephoneType = telType; if (number.IsWork) { phoneProp.Parameters.PropertyClass = VC::Enums.PropertyClassTypes.Work; } } } vcard.TimeStamp = contact.TimeStamp == default ? null : new VC::TimeStampProperty(contact.TimeStamp); return(vcard); }
/// <inheritdoc /> public IUser NewUser(CustomerId?customerId, ExternalUserId externalUserId, Name?name) => new User(externalUserId, name, customerId);
public static object TryParse(this string input, Type targetType, Func <string, object>?preferredParser, Name?argumentName = null) { var parser = preferredParser ?? GetDefaultParser(); return(ArgumentParsingException.ParseWrapper(() => parser(input), targetType, argumentName)); Func <string, object> GetDefaultParser() { if (!DefaultStringParsers.TryGetParser(targetType, out var parser)) { throw ArgumentParsingException.NoParserFound(targetType, argumentName); } return(parser !); } }
public static IEnumerable <T> ValidateIfRequired <T>(this IEnumerable <T> values, IValidation?validation, Name?argumentName = null) { return(values.Select(ValidatedValue)); T ValidatedValue(T value) => value.ValidateIfRequired(validation, argumentName); }