I am developing a mobile application that use bluetooth-lowenergy, i need to create services and characteristics in the application
Thanks
this after two days of search, and by reading this page BLE Android i solved my problem
here the class used to create services
using System;
using Android.App;
using Android.Bluetooth;
using Android.Bluetooth.LE;
using Android.OS;
using Java.Util;
using SitBle.Droid;
using SitBle.Interfaces;
using Exception = System.Exception;
[assembly: Xamarin.Forms.Dependency(typeof(Advertiser))]
namespace SitBle.Droid
{
public class Advertiser : IAdvertiser
{
private BluetoothAdvertiseCallback _advertiseCallback;
private readonly UUID _serviceUuid = UUID.FromString("795090c7-420d-4048-a24e-18e60180e23c");
private readonly UUID _characteristicCounterUuid = UUID.FromString("31517c58-66bf-470c-b662-e352a6c80cba");
private readonly UUID _characteristicInteractorUuid = UUID.FromString("0b89d2d4-0ea6-4141-86bb-0c5fb91ab14a");
private readonly UUID _descriptorConfigUuid = UUID.FromString("00002902-0000-1000-8000-00805f9b34fb");
public void Advertise()
{
try
{
_advertiseCallback = new BluetoothAdvertiseCallback();
var androidBluetoothGattServerCallback = new AndroidBluetoothGattServerCallback();
var adapter = BluetoothAdapter.DefaultAdapter;
var advertiseSettingBuilder = new AdvertiseSettings.Builder()
.SetAdvertiseMode(AdvertiseMode.Balanced).SetConnectable(true).SetTimeout(0)
.SetTxPowerLevel(AdvertiseTx.PowerMedium);
var advertiseSetting = advertiseSettingBuilder.Build();
var adverisingDataBuilder = new AdvertiseData.Builder().SetIncludeDeviceName(false).AddServiceUuid(new ParcelUuid(_serviceUuid));
adapter.BluetoothLeAdvertiser.StartAdvertising(advertiseSetting, adverisingDataBuilder.Build(), _advertiseCallback);
var appContext = Application.Context;
var mBluetoothManager = (BluetoothManager)appContext.GetSystemService("bluetooth");
var mGattServer = mBluetoothManager.OpenGattServer(appContext, androidBluetoothGattServerCallback);
mGattServer.AddService(CreateService());
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
private BluetoothGattService CreateService()
{
BluetoothGattService service = new BluetoothGattService(_serviceUuid, GattServiceType.Primary);
// Counter characteristic (read-only, supports subscriptions)
BluetoothGattCharacteristic counter = new BluetoothGattCharacteristic(_characteristicCounterUuid,GattProperty.Read|GattProperty.Notify,GattPermission.Read);
BluetoothGattDescriptor counterConfig = new BluetoothGattDescriptor(_descriptorConfigUuid, GattDescriptorPermission.Read|GattDescriptorPermission.Write);
counter.AddDescriptor(counterConfig);
// Interactor characteristic
BluetoothGattCharacteristic interactor = new BluetoothGattCharacteristic(_characteristicInteractorUuid, GattProperty.Read|GattProperty.Write|GattProperty.Notify, GattPermission.Write);
service.AddCharacteristic(counter);
service.AddCharacteristic(interactor);
return service;
}
}
public class BluetoothAdvertiseCallback : AdvertiseCallback
{
public BluetoothAdvertiseCallback()
{
}
public override void OnStartSuccess(AdvertiseSettings settingsInEffect)
{
Console.WriteLine("Success");
}
public override void OnStartFailure(AdvertiseFailure errorCode)
{
Console.WriteLine("Fail");
}
}
public class AndroidBluetoothGattServerCallback : BluetoothGattServerCallback
{
public AndroidBluetoothGattServerCallback()
{
}
}
}
Related
I am trying to execute Xamarin App.
I can build and deploy solutions on both Android and iOS devices. But when I am Debugging/running iOS App I am receiving an error
**System.NullReferenceException:** 'Object reference not set to an instance of an object'
on
private static ILogger logger = DependencyService.Get<ILogManager>().GetLog(); line
I have installed the latest version of the Nlog NuGet Package.
My ILogManager file is
namespace VolMobile.AppData.Interfaces
{
public interface ILogManager
{
ILogger GetLog([System.Runtime.CompilerServices.CallerFilePath]string callerFilePath = "");
void Reload();
void DeleteLog();
}
}
How can I resolve this issue?
update
My NLogManager iOS file
using System;
using System.Collections.Generic;
using Xamarin.Forms;
using System.IO;
using NLog;
using NLog.Config;
using NLog.Targets;
using VolMobile.AppData.Interfaces;
using VolMobile.iOS.Logging;
[assembly: Dependency(typeof(NLogManager))]
namespace VolMobile.iOS.Logging
{
public class NLogManager : ILogManager
{
string logFile;
LoggingConfiguration config;
public NLogManager()
{
Reload();
}
public void Reload()
{
config = new LoggingConfiguration();
var consoleTarget = new ConsoleTarget();
config.AddTarget("console", consoleTarget);
var consoleRule = new LoggingRule("*", LogLevel.Trace, consoleTarget);
config.LoggingRules.Add(consoleRule);
//File logging level
LogLevel llSetting = LogLevel.Off;
IEnumerable<LogLevel> sysLevels = LogLevel.AllLevels;
//default to trace at startup
string currentLogLevel = "Trace";
//load the app state if available
if (App.AppState != null)
currentLogLevel = App.AppState.AppSettings.LogLevel;// AppData.AppData.LogLevel;
foreach (LogLevel ll in sysLevels)
{
if (currentLogLevel == ll.Name)
{
llSetting = ll;
}
}
var fileTarget = new FileTarget();
string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments); //android.os.environment is the other option
fileTarget.FileName = Path.Combine(folder, "Log.txt");
fileTarget.Layout = "${longdate}|${level:uppercase=true}|${callsite}|${appdomain}|${logger}|${threadid}|${message}|{exception:format=tostring}";
config.AddTarget("file", fileTarget);
logFile = Path.Combine(folder, "Log.txt");
var fileRule = new LoggingRule("*", llSetting, fileTarget);//LogLevel.Warn
config.LoggingRules.Add(fileRule);
LogManager.Configuration = config;
}
public void DeleteLog()
{
File.Delete(logFile);
}
// Services.Logging.ILogger
//AppData.Interfaces.ILogger
//public NLogLogger GetLog([System.Runtime.CompilerServices.CallerFilePath] string callerFilePath = "")
//{
// string fileName = callerFilePath;
// if (fileName.Contains("/"))
// {
// fileName = fileName.Substring(fileName.LastIndexOf("/", StringComparison.CurrentCultureIgnoreCase) + 1);
// }
// var logger = LogManager.GetLogger(fileName);
// return new NLogLogger(logger, logFile);
//}
public AppData.Interfaces.ILogger GetLog([System.Runtime.CompilerServices.CallerFilePath] string callerFilePath = "")
{
string fileName = callerFilePath;
if (fileName.Contains("/"))
{
fileName = fileName.Substring(fileName.LastIndexOf("/", StringComparison.CurrentCultureIgnoreCase) + 1);
}
var logger = LogManager.GetLogger(fileName);
return new NLogLogger(logger, logFile);
}
}
}
The app is working perfectly fine on iOS, Andriod simulators, and Android Device only not on iOS devices.
How to create mock db tables for the separate class file in test cases to access the service test case and also I need for that tables between parent and child relation
public static class MockTestData
{
// Test data for the DbSet<User> getter
public static IQueryable<EaepTieriiLangComp> Langcomps
{
get
{ return new List<EaepTieriiLangComp>
{
new EaepTieriiLangComp{EaepAssessmentId=1,LangCompId=1,IsPrimary ="Y",LangId =1,LangReadId=1,LangWrittenId=1,LangSpokenId=1,LangUnderstandId=1 },
new EaepTieriiLangComp{EaepAssessmentId=2,LangCompId=1 ,IsPrimary ="N",LangId =2,LangReadId=2,LangWrittenId=2,LangSpokenId=2,LangUnderstandId=2 }//Lang =obj,LangRead=objRead,LangSpoken =objSpeak,LangWritten=objWrite,LangUnderstand=objUnderstand
}.AsQueryable();
}
}
public static IQueryable<LookupLang> LookupLangs
{
get
{ return new List<LookupLang>
{
new LookupLang{LangId = 1,Description = "lang1",IsActive="Y"},
new LookupLang{LangId = 2,Description = "lang2",IsActive="N"}
}.AsQueryable();
}
}
}`
enter code here`
I tried for the above flow but i didnot get relatons for that tables
If you are using EF Core, you can create inmemory database, add data and make query to it.
Here is example:
First you need install Microsoft.EntityFrameworkCore.InMemory package. After this make options:
_options = new DbContextOptionsBuilder<SomeDbContext>()
.UseInMemoryDatabase(databaseName: "DbTest")
.Options;
using var context = new SomeDbContext(_options);
context.Database.EnsureCreated();
Then add your data:
context.AddRange(
new LookupLang{LangId = 1,Description = "lang1",IsActive="Y"},
new LookupLang{LangId = 2,Description = "lang2",IsActive="N"}
)
And now you can use context for testing purposes
Thank you so much advise to use EF core.InMemory package it is working fine now I followed below code
Inmemory class
using Assessments.TierIIQueryDataModel;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Text;
namespace AssessmentCommandTest.Helpers
{
public class InMemoryDataProviderQueryService : IDisposable
{
private bool disposedValue = false; // To detect redundant calls
public DbQueryContext CreateContextForInMemory()
{
var option = new DbContextOptionsBuilder<DbQueryContext>().UseInMemoryDatabase(databaseName: "Test_QueryDatabase").Options;
var context = new DbQueryContext(option);
if (context != null)
{
//context.Database.EnsureDeleted();
context.Database.EnsureCreated();
}
return context;
}
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
}
disposedValue = true;
}
}
public void Dispose()
{
Dispose(true);
}
}
}
and access to DbQueryContext conext file in my code and write mock tables as below
using AssessmentCommandTest.Helpers;
using Assessments.TierIIQueryDataModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AssessmentCommandTest.MockDbTables
{
public class MockQueryDbContext
{
public TierIIQueryContext MockTierIIQueryContexts()
{
//Create object for Inmemory DB provider
var factory = new InMemoryDataProviderQueryService();
//Get the instance of TierIIQueryContext
var context = factory.CreateContextForInMemory();
context.LookupLang.Add(new LookupLang { LangId = 1, Description = "Arabic", IsActive = "Y" });
context.LookupLang.Add(new LookupLang { LangId = 2, Description = "Bangali", IsActive = "Y" });
context.LookupLang.Add(new LookupLang { LangId = 3, Description = "English", IsActive = "Y" });
context.LookupLang.Add(new LookupLang { LangId = 4, Description = "French", IsActive = "Y" });
enter code here
context.SaveChanges();
return context;
}
}
}
Can someone explain to me how to create an instance of this component in a Moq TestMethod? Here is the definition of the class. I need to test the ProcessAutomaticFillRequest method.
public class AutomaticDispenserComponent : IAutomaticDispenserComponent
{
private readonly Lazy<IMessageQueueComponent> _messageQueueComponent;
protected IMessageQueueComponent MessageQueueComponent { get { return _messageQueueComponent.Value; } }
public AutomaticDispenserComponent(Func<IMessageQueueComponent> messageQueueComponentFactory)
{
_messageQueueComponent = new Lazy<IMessageQueueComponent>(messageQueueComponentFactory);
}
public void ProcessAutomaticFillRequest(FillRequestParamDataContract fillRequestParam)
{
if (fillRequestParam.PrescriptionServiceUniqueId == Guid.Empty)
throw new InvalidOperationException("No prescription service was specified for processing fill request.");
if (fillRequestParam.Dispenser == null)
throw new InvalidOperationException("No dispenser was specified for processing fill request.");
var userContext = GlobalContext.CurrentUserContext;
var channel = string.Format(Channel.FillRequest, userContext.TenantId,
userContext.PharmacyUid, fillRequestParam.Dispenser.DeviceAgentUniqueId);
NotificationServer.Publish(channel, fillRequestParam);
}
Here is how I started my test, but I don't know how to create an instance of the component:
[TestMethod]
[ExpectedException(typeof (InvalidOperationException))]
public void FillRequestFailsWhenPrescriptionServiceUniqueIdIsEmpty()
{
// How do I create an instance of automatiqueDispenserComponent here
// since there is Func as constructor parameter?
var fillRequestParam = new FillRequestParamDataContract
{
PrescriptionServiceUniqueId = Guid.Empty
};
_automaticDispensercomponent.ProcessAutomaticFillRequest(fillRequestParam);
// ...
}
Updated the answer based on the comments below. You need to mock the Func parameter for the test.
[TestMethod]
[ExpectedException(typeof(InvalidOperationException))]
public void FillRequestFailsWhenPrescriptionServiceUniqueIdIsEmpty()
{
var mockMsgQueueComponent = new Mock<Func<IMessageQueueComponent>>();
var _automaticDispensercomponent = new AutomaticDispenserComponent
(mockMsgQueueComponent.Object);
var fillRequestParam = new FillRequestParamDataContract
{
PrescriptionServiceUniqueId = Guid.Empty
};
_automaticDispensercomponent.ProcessAutomaticFillRequest(fillRequestParam);
}
"How can i use engine in my console application"
I shouldn't use the ITemplate-interface and Transform-Method.
I am using Tridion 2011
Could anyone please suggest me.
You can't. The Engine class is part of the TOM.NET and that API is explicitly reserved for use in:
Template Building Blocks
Event Handlers
For all other cases (such as console applications) you should use the Core Service.
There are many good questions (and articles on other web sites) already:
https://stackoverflow.com/search?q=%5Btridion%5D+core+service
http://www.google.com/#q=tridion+core+service
If you get stuck along the way, show us the relevant code+configuration you have and what error message your get (or at what step you are stuck) and we'll try to help from there.
From a console application you should use the Core Service. I wrote a small example using the Core Service to search for items in the content manager.
Console.WriteLine("FullTextQuery:");
var fullTextQuery = Console.ReadLine();
if (String.IsNullOrWhiteSpace(fullTextQuery) || fullTextQuery.Equals(":q", StringComparison.OrdinalIgnoreCase))
{
break;
}
Console.WriteLine("SearchIn IdRef:");
var searchInIdRef = Console.ReadLine();
var queryData = new SearchQueryData
{
FullTextQuery = fullTextQuery,
SearchIn = new LinkToIdentifiableObjectData
{
IdRef = searchInIdRef
}
};
var results = coreServiceClient.GetSearchResults(queryData);
results.ToList().ForEach(result => Console.WriteLine("{0} ({1})", result.Title, result.Id));
Add a reference to Tridion.ContentManager.CoreService.Client to your Visual Studio Project.
Code of the Core Service Client Provider:
public interface ICoreServiceProvider
{
CoreServiceClient GetCoreServiceClient();
}
public class CoreServiceDefaultProvider : ICoreServiceProvider
{
private CoreServiceClient _client;
public CoreServiceClient GetCoreServiceClient()
{
return _client ?? (_client = new CoreServiceClient());
}
}
And the client itself:
public class CoreServiceClient : IDisposable
{
public SessionAwareCoreServiceClient ProxyClient;
private const string DefaultEndpointName = "netTcp_2011";
public CoreServiceClient(string endPointName)
{
if(string.IsNullOrWhiteSpace(endPointName))
{
throw new ArgumentNullException("endPointName", "EndPointName is not specified.");
}
ProxyClient = new SessionAwareCoreServiceClient(endPointName);
}
public CoreServiceClient() : this(DefaultEndpointName) { }
public string GetApiVersionNumber()
{
return ProxyClient.GetApiVersion();
}
public IdentifiableObjectData[] GetSearchResults(SearchQueryData filter)
{
return ProxyClient.GetSearchResults(filter);
}
public IdentifiableObjectData Read(string id)
{
return ProxyClient.Read(id, new ReadOptions());
}
public ApplicationData ReadApplicationData(string subjectId, string applicationId)
{
return ProxyClient.ReadApplicationData(subjectId, applicationId);
}
public void Dispose()
{
if (ProxyClient.State == CommunicationState.Faulted)
{
ProxyClient.Abort();
}
else
{
ProxyClient.Close();
}
}
}
When you want to perform CRUD actions through the core service you can implement the following methods in the client:
public IdentifiableObjectData CreateItem(IdentifiableObjectData data)
{
data = ProxyClient.Create(data, new ReadOptions());
return data;
}
public IdentifiableObjectData UpdateItem(IdentifiableObjectData data)
{
data = ProxyClient.Update(data, new ReadOptions());
return data;
}
public IdentifiableObjectData ReadItem(string id)
{
return ProxyClient.Read(id, new ReadOptions());
}
To construct a data object of e.g. a Component you can implement a Component Builder class that implements a create method that does this for you:
public ComponentData Create(string folderUri, string title, string content)
{
var data = new ComponentData()
{
Id = "tcm:0-0-0",
Title = title,
Content = content,
LocationInfo = new LocationInfo()
};
data.LocationInfo.OrganizationalItem = new LinkToOrganizationalItemData
{
IdRef = folderUri
};
using (CoreServiceClient client = provider.GetCoreServiceClient())
{
data = (ComponentData)client.CreateItem(data);
}
return data;
}
Hope this gets you started.
I get a "faulted state" error when working with the Core Service in SDL Tridion 2011 SP1. What's wrong with the following?
namespace coreservice1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
using (ChannelFactory<ISessionAwareCoreService> factory =
new ChannelFactory<ISessionAwareCoreService>("wsHttp_2011"))
{
ISessionAwareCoreService client = factory.CreateChannel();
string SCHEMA_URI = "tcm:7-426-8";
var schemaFields = client.ReadSchemaFields(SCHEMA_URI, true, new ReadOptions());
foreach (var field in schemaFields.Fields)
{
Response.Write(string.Format("{0}", field.Name));
}
Response.Write(schemaFields.NamespaceUri);
string NEW_COMPONENT_FOLDER_URI = "tcm:8-15-2";
Tridion.ContentManager.CoreService.Client.ComponentData component = new Tridion.ContentManager.CoreService.Client.ComponentData
{
Schema = new LinkToSchemaData { IdRef = "tcm:8-426-8"},
Title = "Helloworldalll",
Id = "tcm:0-0-0",
LocationInfo = new LocationInfo
{
OrganizationalItem =
new LinkToOrganizationalItemData { IdRef = NEW_COMPONENT_FOLDER_URI}
},
};
string namespaceUri = schemaFields.NamespaceUri;
System.Text.StringBuilder content = new StringBuilder();
string First = "Hello World.This is Fisrt field";
content.AppendFormat("<{0} xmlns=\"{1}\">", schemaFields.RootElementName, namespaceUri);
content.AppendFormat("<{0} xmlns=\"{1}\">{2}</{0}>", "first", namespaceUri, First);
content.AppendFormat("</{0}>", schemaFields.RootElementName);
component.Content = content.ToString();
ComponentData comp = (ComponentData)client.Create(component, new ReadOptions());
string newlyCreatedComponentID = comp.Id;
Response.Write("Hello hai");
Response.Write("Id of newly created component: " + newlyCreatedComponentID);
}
}
catch (Exception ex)
{
Response.Write(ex.StackTrace);
Response.Write("exception is " + ex.Message);
}
}
}
}
“at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelFactory.OnClose(TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelFactory.TypedServiceChannelFactory`1.OnClose(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout) at System.ServiceModel.ChannelFactory.OnClose(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout) at System.ServiceModel.ChannelFactory.System.IDisposable.Dispose() at coreservice1._Default.Page_Load(Object sender, EventArgs e) in D:\SampleProjects_Tridion\test\coreservice1\coreservice1\coreservice.aspx.cs:line 73exception is The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.“
I think this might be to do with the way you instantiate your client object.
You can add this as Service Reference in Visual Studio:
e.g. Add Service reference to http://{your tridion url}/webservices/CoreService.svc and give it a namespace of TridionCoreService, then you can use it like this:
TridionCoreService.CoreService2010Client client = new TridionCoreService.CoreService2010Client();
Alternatively you can use the method here which allows you to create a Core Service reference without needing a config file.
Sending an example I created time ago in case that helps.....
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoreWebService.ServiceReference1;
namespace CoreWebService
{
class CoreWebServiceSamples
{
public static void createComponent()
{
string schemaWebDavUrl = "/webdav/020%20Content/Building%20Blocks/Content/wstest/wstest.xsd";
string folderWebDavUrl = "/webdav/020%20Content/Building%20Blocks/Content/wstest";
CoreServicesUtil coreServicesUtil = new CoreServicesUtil();
FolderData folderData = coreServicesUtil.getFolderData(folderWebDavUrl);
ComponentData componentData = folderData.AddComponentData();
componentData.Title = "This is a Test ..... ";
componentData.Schema = coreServicesUtil.getLinkToSchemaData(schemaWebDavUrl);
SchemaData schemaData = coreServicesUtil.getSchemaData(schemaWebDavUrl);
componentData.Content = xmlUtil.GetNewXmlNode("Content", schemaData.NamespaceUri);
componentData.Metadata = xmlUtil.GetNewXmlNode("Metadata", schemaData.NamespaceUri);
componentData.AddSingleField("singlefield", "singlefield sample", schemaData.NamespaceUri);
componentData = (ComponentData)coreServicesUtil.coreServiceClient.Save(componentData, coreServicesUtil.readOptions);
coreServicesUtil.coreServiceClient.CheckIn(componentData.Id, coreServicesUtil.readOptions);
coreServicesUtil.coreServiceClient.Close();
}
}
}
The CoreServicesUtil.....
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoreWebService.ServiceReference1;
using CoreWebService.Properties;
using System.Xml;
using System.Xml.Serialization;
namespace CoreWebService
{
public class CoreServicesUtil
{
public CoreService2010Client coreServiceClient;
public ReadOptions readOptions;
/// <summary>
///
/// </summary>
public CoreServicesUtil()
{
this.coreServiceClient = new CoreService2010Client("basicHttp_2010");
this.readOptions = new ReadOptions();
}
public FolderData getFolderData(string tcmuri)
{
FolderData folderData = (FolderData)coreServiceClient.Read(tcmuri,ReadOptions);
return folderData;
}
public LinkToSchemaData getLinkToSchemaData(string tcmuri)
{
LinkToSchemaData linkToSchemaData = new ServiceReference1.LinkToSchemaData();
linkToSchemaData.IdRef = getSchemaData(tcmuri).Id;
return linkToSchemaData;
}
public SchemaData getSchemaData(string tcmuri)
{
SchemaData schemaData = (SchemaData)coreServiceClient.Read(tcmuri, readOptions);
return schemaData;
}
}
}
The XMLUtil ....
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
namespace CoreWebService
{
public class xmlUtil
{
/**
* <summary>
* Name: enumeration
* </summary>
**/
public enum Scope
{
Content,
Metadata
}
/**
* <summary>
* Name: AddItemLinkFieldGeneric
* Description: basic method for add component links, multimedia links, keyword field to an XmlElement
* </summary>
**/
/**
* <summary>
* Name: getXMLElementData
* Description: adds a single field to an XmlElement
* </summary>
**/
public static XmlElement getXMLElementData(string dataNode)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(dataNode);
return doc.DocumentElement;
}
/**
* <summary>
* Name: GetNewXmlNode
* Description: returns an xml element based on the name and schema
* </summary>
**/
public static string GetNewXmlNode(string Name, string Namespace)
{
XmlDocument doc = new XmlDocument();
XmlElement xmlElem = doc.CreateElement(Name, Namespace);
doc.AppendChild(xmlElem);
return doc.FirstChild.OuterXml;
}
}
}
Does it actually create the component? Do you get that far?
I normally write a wrapper class for CoreService, implement IDisposable and use the following methods in it:
private void InitializeClient()
{
NetTcpBinding binding = new NetTcpBinding { MaxReceivedMessageSize = 2147483647 };
XmlDictionaryReaderQuotas quota = new XmlDictionaryReaderQuotas
{
MaxStringContentLength = 2147483647,
MaxArrayLength = 2147483647
};
binding.ReaderQuotas = quota;
_client = new SessionAwareCoreServiceClient(binding, _endpointAddress);
if (_client != null) _coreServiceVersion = _client.GetApiVersion();
}
and
public void Dispose()
{
if (_client.State == CommunicationState.Faulted)
{
_client.Abort();
}
else
{
_client.Close();
}
}