/// <summary> /// 发布一条新微博 /// </summary> /// <param name="channelName"></param> /// <param name="channelUrl"></param> /// <param name="message"></param> protected override void SocialSharePublish(string channelName, string channelUrl, string message, SocialBase.SocialShareHandler callBack) { var social = SocialViewModel.Instance.DataInfos[SocialType.TENCENT]; OAuthConfigruation.AccessToken = new AccessToken(social.AcessToken); var share = new TService(); var arg = new ServiceArgument() { Content = message, Url = channelUrl }; try { share.AddVideo(arg, obj => { if (obj.Succeed) callBack(true, string.Empty); else callBack(false, obj.InnerException.Message); }); } catch (Exception ex) { callBack(false, ex.Message); } }
public Editor( TService service, SemanticDocument document, State state, bool intoNamespace, bool inNewFile, CancellationToken cancellationToken) { _service = service; _semanticDocument = document; _state = state; _intoNamespace = intoNamespace; _inNewFile = inNewFile; _cancellationToken = cancellationToken; }
public GenerateTypeCodeAction( TService service, Document document, State state, bool intoNamespace, bool inNewFile ) { _service = service; _document = document; _state = state; _intoNamespace = intoNamespace; _inNewFile = inNewFile; _equivalenceKey = Title; }
public async static Task <State> GenerateAsync( TService service, SemanticDocument document, TextSpan textSpan, CancellationToken cancellationToken) { var state = new State(service, document); if (!await state.TryInitializeAsync(document, textSpan, cancellationToken).ConfigureAwait(false)) { return(null); } return(state); }
public Editor( TService service, SemanticDocument document, State state, bool fromDialog, GenerateTypeOptionsResult generateTypeOptionsResult, CancellationToken cancellationToken) { _service = service; _document = document; _state = state; _fromDialog = fromDialog; _generateTypeOptionsResult = generateTypeOptionsResult; _cancellationToken = cancellationToken; }
private bool GenerateInterface( TService service, CancellationToken cancellationToken) { if (!this.IsAttribute && !this.IsException && this.Name.LooksLikeInterfaceName() && this.ObjectCreationExpressionOpt == null && (this.BaseTypeOrInterfaceOpt == null || this.BaseTypeOrInterfaceOpt.TypeKind == TypeKind.Interface)) { return(true); } return(service.IsInInterfaceList(this.NameOrMemberAccessExpression)); }
/// <summary> /// 获取InstancePerHttpRequest的组件 /// </summary> /// <typeparam name="TService">组件类型</typeparam> public static TService ResolvePerHttpRequest <TService>() { IDependencyResolver dependencyResolver = DependencyResolver.Current; if (dependencyResolver != null) { TService tService = (TService)dependencyResolver.GetService(typeof(TService)); if (tService != null) { return(tService); } } return(_container.Resolve <TService>()); }
public static async Task <State> GenerateAsync( TService service, SemanticDocument document, SyntaxNode interfaceNode, CancellationToken cancellationToken) { var state = new State(); if (!await state.TryInitializeAsync(service, document, interfaceNode, cancellationToken).ConfigureAwait(false)) { return(null); } return(state); }
public GenerateParameterizedMemberCodeAction( TService service, Document document, State state, bool isAbstract, bool generateProperty ) { _service = service; _document = document; _state = state; _isAbstract = isAbstract; _generateProperty = generateProperty; _equivalenceKey = Title; }
internal static async Task <State> GenerateAsync( TService service, Document document, TLocalDeclarationStatementSyntax statement, CancellationToken cancellationToken) { var state = new State(); if (!await state.TryInitializeAsync(service, document, statement, cancellationToken).ConfigureAwait(false)) { return(null); } return(state); }
public static State Generate( TService service, SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken) { var state = new State(document.SemanticModel.Compilation); if (!state.TryInitialize(service, document, node, cancellationToken)) { return(null); } return(state); }
public TService Register <TService>() where TService : TServiceInterface { Type serviceType = typeof(TService); if (services.ContainsKey(serviceType)) { throw new InvalidOperationException($"{serviceType} has already been registered."); } TService serviceInstance = (TService)Activator.CreateInstance(serviceType); services.Add(serviceType, serviceInstance); return(serviceInstance); }
// GET: TServices/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TService tService = db.TServices.Find(id); if (tService == null) { return(HttpNotFound()); } ViewBag.intServiceTypeID = new SelectList(db.TServiceTypes, "intServiceTypeID", "strServiceType", tService.intServiceTypeID); return(View(tService)); }
public static State Generate( TService service, SemanticDocument document, TextSpan textSpan, CancellationToken cancellationToken) { var state = new State(service, document); if (!state.TryInitialize(textSpan, cancellationToken)) { return(null); } return(state); }
public GenerateVariableCodeAction( TService service, Document document, State state, bool generateProperty, bool isReadonly, bool isConstant) { this.service = service; this.document = document; this.state = state; this.generateProperty = generateProperty; this.isReadonly = isReadonly; this.isConstant = isConstant; this.equivalenceKey = Title; }
public static TService GetService <TService>() where TService : Service, new() { Type serviceType = typeof(TService); Service service = null; if (!servicesDic.TryGetValue(serviceType, out service)) { if (!serviceType.Name.EndsWith("Service")) { throw new CoreException(string.Format("[Core.GetService]The service named {0} is not end with \"Service\" ", serviceType.Name)); } service = new TService(); servicesDic.Add(serviceType, service); } return(service as TService); }
public static State Generate( TService service, Document document, TextSpan textSpan, IList <ISymbol> selectedMembers, CancellationToken cancellationToken) { var state = new State(); if (!state.TryInitialize(service, document, textSpan, selectedMembers, cancellationToken)) { return(null); } return(state); }
public GenerateVariableCodeAction( TService service, Document document, State state, bool generateProperty, bool isReadonly, bool isConstant) { //_service = service; _document = document; _state = state; _generateProperty = generateProperty; _isReadonly = isReadonly; _isConstant = isConstant; _equivalenceKey = Title; }
public GenerateTypeCodeAction( TService service, Document document, State state, CleanCodeGenerationOptionsProvider fallbackOptions, bool intoNamespace, bool inNewFile) { _service = service; _document = document; _state = state; _fallbackOptions = fallbackOptions; _intoNamespace = intoNamespace; _inNewFile = inNewFile; _equivalenceKey = Title; }
public GenerateParameterizedMemberCodeAction( TService service, Document document, State state, CodeAndImportGenerationOptionsProvider fallbackOptions, bool isAbstract, bool generateProperty) { _service = service; _document = document; _state = state; _fallbackOptions = fallbackOptions; _isAbstract = isAbstract; _generateProperty = generateProperty; _equivalenceKey = Title; }
public static State?Generate( TService service, SemanticDocument document, TextSpan textSpan, bool forRefactoring, CancellationToken cancellationToken) { var state = new State(); if (!state.TryInitialize(service, document, textSpan, forRefactoring, cancellationToken)) { return(null); } return(state); }
private bool TryInitialize( TService service, SemanticDocument semanticDocument, TextSpan textSpan, CancellationToken cancellationToken ) { if ( !service.TryInitializeState( semanticDocument, textSpan, cancellationToken, out var classType ) ) { return(false); } ClassType = classType; var baseType = ClassType.BaseType; if (ClassType.IsStatic || baseType == null || baseType.TypeKind == TypeKind.Error) { return(false); } var semanticFacts = semanticDocument.Document.GetLanguageService <ISemanticFactsService>(); var classConstructors = ClassType.InstanceConstructors; var destinationProvider = semanticDocument.Project.Solution.Workspace.Services.GetLanguageServices( ClassType.Language ); var syntaxFacts = destinationProvider.GetService <ISyntaxFactsService>(); var isCaseSensitive = syntaxFacts.IsCaseSensitive; UnimplementedConstructors = baseType.InstanceConstructors.WhereAsArray( c => c.IsAccessibleWithin(ClassType) && IsMissing(c, classConstructors, isCaseSensitive) ); return(UnimplementedConstructors.Length > 0); }
public static async Task <State?> GenerateAsync( TService service, SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken ) { var fieldNamingRule = await document.Document .GetApplicableNamingRuleAsync( SymbolKind.Field, Accessibility.Private, cancellationToken ) .ConfigureAwait(false); var propertyNamingRule = await document.Document .GetApplicableNamingRuleAsync( SymbolKind.Property, Accessibility.Public, cancellationToken ) .ConfigureAwait(false); var parameterNamingRule = await document.Document .GetApplicableNamingRuleAsync( SymbolKind.Parameter, Accessibility.NotApplicable, cancellationToken ) .ConfigureAwait(false); var state = new State( service, document, fieldNamingRule, propertyNamingRule, parameterNamingRule ); if (!await state.TryInitializeAsync(node, cancellationToken).ConfigureAwait(false)) { return(null); } return(state); }
private State( TService service, SemanticDocument document, NamingRule fieldNamingRule, NamingRule propertyNamingRule, NamingRule parameterNamingRule ) { _service = service; _document = document; _fieldNamingRule = fieldNamingRule; _propertyNamingRule = propertyNamingRule; _parameterNamingRule = parameterNamingRule; ParameterToNewFieldMap = ImmutableDictionary <string, string> .Empty; ParameterToNewPropertyMap = ImmutableDictionary <string, string> .Empty; }
/// <summary> /// 获取InstancePerHttpRequest的组件 /// </summary> /// <typeparam name="TService">组件类型</typeparam> public static TService ResolvePerHttpRequest <TService>() { System.Web.Mvc.IDependencyResolver dependencyResolver = System.Web.Mvc.DependencyResolver.Current; if (dependencyResolver != null) { TService tService = (TService)dependencyResolver.GetService(typeof(TService)); if (tService != null) { return(tService); } } using (var scope = _container.BeginLifetimeScope()) { return(_container.Resolve <TService>()); } }
public ClientHandler( TcpClient client, TService serviceInstance, ServerSslSettings sslSettings, ISerializer <RpcMessage> messageSerializer, ISerializer <ServiceCallResult> serviceCallResultSerializer, ServiceDispatcher <TService> serviceDispatcher, ILogger logger) { _client = client; _serviceInstance = serviceInstance; _sslSettings = sslSettings; _messageSerializer = messageSerializer; _serviceDispatcher = serviceDispatcher; _logger = logger; _serviceCallResultSerializer = serviceCallResultSerializer; }
public GenerateEqualsAndHashCodeAction( TService service, Document document, TextSpan textSpan, INamedTypeSymbol containingType, IList <ISymbol> selectedMembers, bool generateEquals = false, bool generateGetHashCode = false) { _service = service; _document = document; _containingType = containingType; _selectedMembers = selectedMembers; _textSpan = textSpan; _generateEquals = generateEquals; _generateGetHashCode = generateGetHashCode; }
/// <summary> Create child service and set this as parent </summary> public virtual TService GetChildService <TService>() where TService : IBaseService { TService service = default; try { service = HttpContext.RequestServices.GetRequiredService <TService>(); service.Parent = this; service.IsTransactionEnabled = this.IsTransactionEnabled; } catch (Exception ex) { var errorMessage = $"Serice {typeof(TService).Name} not registred {ex.GetApiMessageInfo()}"; throw new InvalidOperationException(GeneralContext.GetApiMessageInfo(errorMessage, EventLevel.Critical)); } return(service); }
public void Decorate <TService, TImplementation>() where TImplementation : TService { Type serviceType = typeof(TService); Type implementationType = typeof(TImplementation); TService decorated = GetService <TService>(); if (decorated == null) { throw new InvalidOperationException($"Can not register decorator {implementationType}, if no decorated service of {serviceType} has be registered."); } var decorator = CreateService(implementationType); _serviceDescriptors.Remove(serviceType); _serviceDescriptors.Add(serviceType, () => decorator); }
public Editor( TService service, SemanticDocument document, State state, CodeAndImportGenerationOptionsProvider fallbackOptions, bool intoNamespace, bool inNewFile, CancellationToken cancellationToken) { _service = service; _semanticDocument = document; _state = state; _fallbackOptions = fallbackOptions; _intoNamespace = intoNamespace; _inNewFile = inNewFile; _cancellationToken = cancellationToken; }
private bool TryInitializeExplicitInterface( TService service, SemanticDocument document, SyntaxNode propertyDeclaration, CancellationToken cancellationToken) { if (!service.TryInitializeExplicitInterfaceState( document, propertyDeclaration, cancellationToken, out var identifierToken, out var propertySymbol, out var typeToGenerateIn)) { return(false); } this.IdentifierToken = identifierToken; this.TypeToGenerateIn = typeToGenerateIn; if (propertySymbol.ExplicitInterfaceImplementations.Any()) { return(false); } cancellationToken.ThrowIfCancellationRequested(); var semanticModel = document.SemanticModel; this.ContainingType = semanticModel.GetEnclosingNamedType(this.IdentifierToken.SpanStart, cancellationToken); if (this.ContainingType == null) { return(false); } if (!this.ContainingType.Interfaces.OfType <INamedTypeSymbol>().Contains(this.TypeToGenerateIn)) { return(false); } this.IsIndexer = propertySymbol.IsIndexer; this.Parameters = propertySymbol.Parameters; this.TypeMemberType = propertySymbol.Type; // By default, make it readonly, unless there's already an setter defined. this.IsWrittenTo = propertySymbol.SetMethod != null; return(true); }